Package translate :: Package misc :: Module textwrap |
[hide private]
[frames] | no frames]

# Module textwrap

source code

Text wrapping and filling.

Classes | [hide private]
| TextWrapper Object for wrapping/filling text.

Functions | [hide private]
wrap(text, width=70, **kwargs) Wrap a single paragraph of text, returning a list of wrapped lines. | source code
fill(text, width=70, **kwargs) Fill a single paragraph of text, returning a new string. | source code
dedent(text) Remove any common leading whitespace from every line in `text`. | source code

Variables | [hide private]
| __revision__ = ``'``$Id: textwrap.py 9228 2008-12-13 04:50:49Z fri``...``
| _whitespace = ``'``\t\n\x0b\x0c\r` `'``
| _whitespace_only_re = `re.compile(r'`(?m)`^`[` \t`]``+`$')`
| _leading_whitespace_re = `re.compile(r'`(?m)``(`^`[` \t`]``*``)``(?:``[``^` \t\n`]``)`')`

Imports: string, re

Function Details | [hide private]

### wrap(text, width=70, **kwargs) | source code
Wrap a single paragraph of text, returning a list of wrapped lines. Reformat the single paragraph in 'text' so it fits in lines of no more than 'width' columns, and return a list of wrapped lines. By default, tabs in 'text' are expanded with string.expandtabs(), and all other whitespace characters (including newline) are converted to space. See TextWrapper class for available keyword args to customize wrapping behaviour.

### fill(text, width=70, **kwargs) | source code
Fill a single paragraph of text, returning a new string. Reformat the single paragraph in 'text' to fit in lines of no more than 'width' columns, and return a new string containing the entire wrapped paragraph. As with wrap(), tabs are expanded and other whitespace characters converted to space. See TextWrapper class for available keyword args to customize wrapping behaviour.

### dedent(text) | source code
Remove any common leading whitespace from every line in `text`. This can be used to make triple-quoted strings line up with the left edge of the display, while still presenting them in the source code in indented form. Note that tabs and spaces are both treated as whitespace, but they are not equal: the lines " hello" and " hello" are considered to have no common leading whitespace. (This behaviour is new in Python 2.5; older versions of this module incorrectly expanded tabs before searching for common leading whitespace.)

Variables Details | [hide private]

  ### __revision__ Value:
      '$Id: textwrap.py 9228 2008-12-13 04:50:49Z friedelwolff $'