indent#

indent(prefix=None, text=None, suffix='\n', n=0, pretty=False, width=70, **kwargs)[source]#

Small wrapper to make textwrap more user friendly.

Parameters:
  • prefix (str) – text to begin with (optional)

  • text (str) – text to wrap

  • suffix (str) – what to put on the end (by default, a newline)

  • n (int) – if prefix is not specified, the size of the indent

  • pretty (bool) – whether to use pprint to format the text

  • width (int) – maximum width before wrapping (if None, don’t wrap)

  • kwargs (dict) – passed to textwrap.fill()

Examples:

prefix = 'and then they said: '
text = 'blah '*100
print(sc.indent(prefix, text))

print('my fave is: ' + sc.indent(text=rand(100), n=12))

New in version 1.3.1: more flexibility in arguments