ID EN
Text Wrapping

TextWrapper

Python 3.11

The TextWrapper constructor accepts a number of optional keyword arguments. Each keyword argument corresponds to an instance attribute, so for example

Syntax

PYTHON
class textwrap.TextWrapper(**kwargs)

Examples

Example 1
PYTHON
wrapper = TextWrapper(initial_indent="* ")
Example 2
PYTHON
wrapper = TextWrapper()
wrapper.initial_indent = "* "
Example 3
PYTHON
[...] Dr. Frankenstein's monster [...]
Example 4
PYTHON
[...] See Spot. See Spot run [...]

See Also

TextWrapper TextWrapper TextWrapper width TextWrapper width expandtabs() expand_tabs