On this page
  1. textwrap.indent
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

textwrap.indent

Prev: textwrap.fill | Up: textwrap | Next: textwrap.shorten
Rel: textwrap.dedent, textwrap.fill, textwrap.shorten, textwrap.TextWrapper
Ref: docs.python.org — textwrap.indent
Tags: #public #python3 #stdlib #textwrap


Import

import textwrap
from textwrap import indent

Signature & Overview

textwrap.indent(text, prefix, predicate=None)

Adds 'prefix' to the beginning of selected lines in 'text'.

Usage

import textwrap

assert textwrap.indent('a\n\nb\n', '> ') == '> a\n\n> b\n'

Gotchas

REPL Inspect

from textwrap import indent
help(indent)

Linked from

Related notes