Text wrapping and filling.
Imported modules
|
|
import re
import string
|
Functions
|
|
dedent
fill
wrap
|
|
dedent
|
dedent ( text )
dedent(text : string) -> string
Remove any whitespace than can be uniformly removed from the left
of every line in `text`.
This can be used e.g. to make triple-quoted strings line up with
the left edge of screen/whatever, while still presenting it in the
source code in indented form.
For example:
def test():
# end first line with \ to avoid the empty line!
s = ''' hello
world
''
print repr(s) # prints hello
world
'
print repr(dedent(s)) # prints hello
world
|
|
fill
|
fill (
text,
width=70,
**kwargs,
)
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.
|
|
wrap
|
wrap (
text,
width=70,
**kwargs,
)
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.
|
Classes
|
|
TextWrapper |
Object for wrapping/filling text. The public interface consists of
|
|
|