PyDocs

Nav

Text Processing Services

indent

textwrap

function · Added in 3.3 (source)
  • indent(text, prefix, predicate=None)
Adds 'prefix' to the beginning of selected lines in 'text'.

If 'predicate' is provided, 'prefix' will only be added to the lines
where 'predicate(line)' is True. If 'predicate' is not provided,
it will default to adding 'prefix' to all non-empty lines that do not
consist solely of whitespace characters.
1 Example
>>> s = 'hello\n\n \nworld'
>>> indent(s, '  ')
'  hello\n\n \n  world'
from the Python docs
See Also
No see-alsos for textwrap/indent
0 Notes
No notes for indent