[Python-checkins] python/dist/src/Lib textwrap.py,1.11,1.12
gward@users.sourceforge.net
gward@users.sourceforge.net
Thu, 04 Jul 2002 07:51:52 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv28697
Modified Files:
textwrap.py
Log Message:
Docstring improvements. In particular, added docstrings for the
standalone wrap() and fill() functions.
Index: textwrap.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** textwrap.py 10 Jun 2002 21:37:12 -0000 1.11
--- textwrap.py 4 Jul 2002 14:51:49 -0000 1.12
***************
*** 1,4 ****
! """
! Utilities for wrapping text strings and filling text paragraphs.
"""
--- 1,3 ----
! """Text wrapping and filling.
"""
***************
*** 232,240 ****
"""wrap(text : string) -> [string]
! Split 'text' into multiple lines of no more than 'self.width'
! characters each, and return the list of strings that results.
! Tabs in 'text' are expanded with string.expandtabs(), and all
! other whitespace characters (including newline) are converted to
! space.
"""
text = self._munge_whitespace(text)
--- 231,239 ----
"""wrap(text : string) -> [string]
! Reformat the single paragraph in 'text' so it fits in lines of
! no more than 'self.width' columns, and return a list of wrapped
! lines. Tabs in 'text' are expanded with string.expandtabs(),
! and all other whitespace characters (including newline) are
! converted to space.
"""
text = self._munge_whitespace(text)
***************
*** 249,265 ****
"""fill(text : string) -> string
! Reformat the paragraph in 'text' to fit in lines of no more than
! 'width' columns.
"""
return "\n".join(self.wrap(text))
! # Convenience interface
def wrap(text, width=70, **kwargs):
w = TextWrapper(width=width, **kwargs)
return w.wrap(text)
def fill(text, width=70, **kwargs):
w = TextWrapper(width=width, **kwargs)
return w.fill(text)
--- 248,282 ----
"""fill(text : string) -> string
! Reformat the single paragraph in 'text' to fit in lines of no
! more than 'self.width' columns, and return a new string
! containing the entire wrapped paragraph.
"""
return "\n".join(self.wrap(text))
! # -- Convenience interface ---------------------------------------------
def 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.
+ """
w = TextWrapper(width=width, **kwargs)
return w.wrap(text)
def 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.
+ """
w = TextWrapper(width=width, **kwargs)
return w.fill(text)