textwrap.TextWrapper.drop_whitespace

drop_whitespace (default: True) If true, whitespace at the beginning and ending of every line (after wrapping but before indenting) is dropped. Whitespace at the beginning of the paragraph, however, is not dropped if non-whitespace follows it. If whitespace being dropped takes up an entire line, the whole line is dropped.

textwrap.TextWrapper.break_on_hyphens

break_on_hyphens (default: True) If true, wrapping will occur preferably on whitespaces and right after hyphens in compound words, as it is customary in English. If false, only whitespaces will be considered as potentially good places for line breaks, but you need to set break_long_words to false if you want truly insecable words. Default behaviour in previous versions was to always allow breaking hyphenated words.

textwrap.TextWrapper.break_long_words

break_long_words (default: True) If true, then words longer than width will be broken in order to ensure that no lines are longer than width. If it is false, long words will not be broken, and some lines may be longer than width. (Long words will be put on a line by themselves, in order to minimize the amount by which width is exceeded.)

textwrap.TextWrapper

class textwrap.TextWrapper(**kwargs) The TextWrapper constructor accepts a number of optional keyword arguments. Each keyword argument corresponds to an instance attribute, so for example wrapper = TextWrapper(initial_indent="* ") is the same as wrapper = TextWrapper() wrapper.initial_indent = "* " You can re-use the same TextWrapper object many times, and you can change any of its options through direct assignment to instance attributes between uses. The TextWrapper instance attributes (a

textwrap.shorten()

textwrap.shorten(text, width, **kwargs) Collapse and truncate the given text to fit in the given width. First the whitespace in text is collapsed (all whitespace is replaced by single spaces). If the result fits in the width, it is returned. Otherwise, enough words are dropped from the end so that the remaining words plus the placeholder fit within width: >>> textwrap.shorten("Hello world!", width=12) 'Hello world!' >>> textwrap.shorten("Hello world!", width=11) 'Hello [.

textwrap.indent()

textwrap.indent(text, prefix, predicate=None) Add prefix to the beginning of selected lines in text. Lines are separated by calling text.splitlines(True). By default, prefix is added to all lines that do not consist solely of whitespace (including any line endings). For example: >>> s = 'hello\n\n \nworld' >>> indent(s, ' ') ' hello\n\n \n world' The optional predicate argument can be used to control which lines are indented. For example, it is easy to add prefix to eve

textwrap.fill()

textwrap.fill(text, width=70, **kwargs) Wraps the single paragraph in text, and returns a single string containing the wrapped paragraph. fill() is shorthand for "\n".join(wrap(text, ...)) In particular, fill() accepts exactly the same keyword arguments as wrap().

textwrap.dedent()

textwrap.dedent(text) 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 "\thello" are considered to have no common leading whitespace. For example: def test(): # end first line with \ to avoid the empty line! s = ''

test.support.WarningsRecorder

class test.support.WarningsRecorder Class used to record warnings for unit tests. See documentation of check_warnings() above for more details.

test.support.verbose

test.support.verbose True when verbose output is enabled. Should be checked when more detailed information is desired about a running test. verbose is set by test.regrtest.