summaryrefslogtreecommitdiffstats
path: root/Doc/library/textwrap.rst
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-09-08 17:14:58 (GMT)
committerR David Murray <rdmurray@bitdance.com>2012-09-08 17:14:58 (GMT)
commit0fbbce99c39f4219610e4c675be47cbefe6739cb (patch)
treeb897ed98d7aa2f08c2506d4ec4cf80bd95cc0ae7 /Doc/library/textwrap.rst
parent63755f3bd94c7e193a44324d3248b2478cbf47fc (diff)
parent1585b708139f9b431081229fb664b9638a5062b8 (diff)
downloadcpython-0fbbce99c39f4219610e4c675be47cbefe6739cb.zip
cpython-0fbbce99c39f4219610e4c675be47cbefe6739cb.tar.gz
cpython-0fbbce99c39f4219610e4c675be47cbefe6739cb.tar.bz2
Merge #15510: clarify textwrap's handling of whitespace, and add confirming tests.
Patch by Chris Jerdonek.
Diffstat (limited to 'Doc/library/textwrap.rst')
-rw-r--r--Doc/library/textwrap.rst19
1 files changed, 13 insertions, 6 deletions
diff --git a/Doc/library/textwrap.rst b/Doc/library/textwrap.rst
index 0ac1cc6..c625254 100644
--- a/Doc/library/textwrap.rst
+++ b/Doc/library/textwrap.rst
@@ -25,6 +25,9 @@ otherwise, you should use an instance of :class:`TextWrapper` for efficiency.
Optional keyword arguments correspond to the instance attributes of
:class:`TextWrapper`, documented below. *width* defaults to ``70``.
+ See the :meth:`TextWrapper.wrap` method for additional details on how
+ :func:`wrap` behaves.
+
.. function:: fill(text, width=70, **kwargs)
@@ -167,15 +170,18 @@ in a block of text.
.. attribute:: drop_whitespace
- (default: ``True``) If true, whitespace that, after wrapping, happens to
- end up at the beginning or end of a line is dropped (leading whitespace in
- the first line is always preserved, though).
+ (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.
.. attribute:: initial_indent
(default: ``''``) String that will be prepended to the first line of
- wrapped output. Counts towards the length of the first line.
+ wrapped output. Counts towards the length of the first line. The empty
+ string is not indented.
.. attribute:: subsequent_indent
@@ -236,8 +242,9 @@ in a block of text.
Wraps the single paragraph in *text* (a string) so every line is at most
:attr:`width` characters long. All wrapping options are taken from
- instance attributes of the :class:`TextWrapper` instance. Returns a list
- of output lines, without final newlines.
+ instance attributes of the :class:`TextWrapper` instance. Returns a list
+ of output lines, without final newlines. If the wrapped output has no
+ content, the returned list is empty.
.. method:: fill(text)