[Python-checkins] python/dist/src/Doc/lib libtextwrap.tex,1.4,1.5

gward@users.sourceforge.net gward@users.sourceforge.net
Wed, 07 May 2003 19:09:52 -0700


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv3249

Modified Files:
	libtextwrap.tex 
Log Message:
SF patch #598163 (Ville Vainio, vvainio@users.sourceforge.net):
document dedent() function.


Index: libtextwrap.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtextwrap.tex,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** libtextwrap.tex	3 Jul 2002 05:08:48 -0000	1.4
--- libtextwrap.tex	8 May 2003 02:09:49 -0000	1.5
***************
*** 11,18 ****
  The \module{textwrap} module provides two convenience functions,
  \function{wrap()} and \function{fill()}, as well as
! \class{TextWrapper}, the class that does all the work.  If you're just
! wrapping or filling one or two text strings, the convenience functions
! should be good enough; otherwise, you should use an instance of
! \class{TextWrapper} for efficiency.
  
  \begin{funcdesc}{wrap}{text\optional{, width\optional{, \moreargs}}}
--- 11,18 ----
  The \module{textwrap} module provides two convenience functions,
  \function{wrap()} and \function{fill()}, as well as
! \class{TextWrapper}, the class that does all the work, and a utility function 
! \function{dedent()}.  If you're just wrapping or filling one or two 
! text strings, the convenience functions should be good enough; otherwise, 
! you should use an instance of \class{TextWrapper} for efficiency.
  
  \begin{funcdesc}{wrap}{text\optional{, width\optional{, \moreargs}}}
***************
*** 42,45 ****
--- 42,70 ----
  strings, it will be more efficient for you to create your own
  \class{TextWrapper} object.
+ 
+ An additional utility function, \function{dedent()}, is provided to
+ remove indentation from strings that have unwanted whitespace to the
+ left of the text.
+ 
+ \begin{funcdesc}{dedent}{text} 
+ Remove any whitespace than can be uniformly removed from the left
+ of every line in \var{text}.
+ 
+ This is typically used 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:
+ \begin{verbatim}
+ def test():
+     # end first line with \ to avoid the empty line!
+     s = '''\
+     Hey
+     there
+     '''
+     print repr(s)          # prints '    Hey\n    there\n    '
+     print repr(dedent(s))  # prints 'Hey\nthere\n'
+ \end{verbatim}
+ \end{funcdesc}
  
  \begin{classdesc}{TextWrapper}{...}