Changeset 391 for python/trunk/Doc/library/textwrap.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/textwrap.rst
r2 r391 1 2 1 :mod:`textwrap` --- Text wrapping and filling 3 2 ============================================= … … 8 7 .. sectionauthor:: Greg Ward <gward@python.net> 9 8 10 11 9 .. versionadded:: 2.3 10 11 **Source code:** :source:`Lib/textwrap.py` 12 13 -------------- 12 14 13 15 The :mod:`textwrap` module provides two convenience functions, :func:`wrap` and … … 17 19 otherwise, you should use an instance of :class:`TextWrapper` for efficiency. 18 20 19 20 21 .. function:: wrap(text[, width[, ...]]) 21 22 … … 25 26 Optional keyword arguments correspond to the instance attributes of 26 27 :class:`TextWrapper`, documented below. *width* defaults to ``70``. 28 29 See the :meth:`TextWrapper.wrap` method for additional details on how 30 :func:`wrap` behaves. 27 31 28 32 … … 112 116 .. attribute:: replace_whitespace 113 117 114 (default: ``True``) If true, each whitespace character (as defined by 115 ``string.whitespace``) remaining after tab expansion will be replaced by a 116 single space. 118 (default: ``True``) If true, after tab expansion but before wrapping, 119 the :meth:`wrap` method will replace each whitespace character 120 with a single space. The whitespace characters replaced are 121 as follows: tab, newline, vertical tab, formfeed, and carriage 122 return (``'\t\n\v\f\r'``). 117 123 118 124 .. note:: … … 122 128 the same as tab expansion. 123 129 130 .. note:: 131 132 If :attr:`replace_whitespace` is false, newlines may appear in the 133 middle of a line and cause strange output. For this reason, text should 134 be split into paragraphs (using :meth:`str.splitlines` or similar) 135 which are wrapped separately. 136 124 137 125 138 .. attribute:: drop_whitespace 126 139 127 (default: ``True``) If true, whitespace that, after wrapping, happens to 128 end up at the beginning or end of a line is dropped (leading whitespace in 129 the first line is always preserved, though). 140 (default: ``True``) If true, whitespace at the beginning and ending of 141 every line (after wrapping but before indenting) is dropped. 142 Whitespace at the beginning of the paragraph, however, is not dropped 143 if non-whitespace follows it. If whitespace being dropped takes up an 144 entire line, the whole line is dropped. 130 145 131 146 .. versionadded:: 2.6 … … 136 151 137 152 (default: ``''``) String that will be prepended to the first line of 138 wrapped output. Counts towards the length of the first line. 153 wrapped output. Counts towards the length of the first line. The empty 154 string is not indented. 139 155 140 156 … … 199 215 Wraps the single paragraph in *text* (a string) so every line is at most 200 216 :attr:`width` characters long. All wrapping options are taken from 201 instance attributes of the :class:`TextWrapper` instance. Returns a list 202 of output lines, without final newlines. 217 instance attributes of the :class:`TextWrapper` instance. Returns a list 218 of output lines, without final newlines. If the wrapped output has no 219 content, the returned list is empty. 203 220 204 221
Note:
See TracChangeset
for help on using the changeset viewer.