[Python-checkins] cpython (merge 3.3 -> default): Issue #17670: merge from 3.3

ned.deily python-checkins at python.org
Sun Apr 21 22:07:58 CEST 2013


http://hg.python.org/cpython/rev/1a6cb6d8591a
changeset:   83485:1a6cb6d8591a
parent:      83481:c7806d1b09eb
parent:      83484:5b6ccab52a4d
user:        Ned Deily <nad at acm.org>
date:        Sun Apr 21 13:07:27 2013 -0700
summary:
  Issue #17670: merge from 3.3

files:
  Doc/library/stdtypes.rst |  22 +++++++++++++++++-----
  1 files changed, 17 insertions(+), 5 deletions(-)


diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1526,11 +1526,23 @@
 
 .. method:: str.expandtabs([tabsize])
 
-   Return a copy of the string where all tab characters are replaced by zero or
-   more spaces, depending on the current column and the given tab size.  The
-   column number is reset to zero after each newline occurring in the string.
-   If *tabsize* is not given, a tab size of ``8`` characters is assumed.  This
-   doesn't understand other non-printing characters or escape sequences.
+   Return a copy of the string where all tab characters are replaced by one or
+   more spaces, depending on the current column and the given tab size.  Tab
+   positions occur every *tabsize* characters (default is 8, giving tab
+   positions at columns 0, 8, 16 and so on).  To expand the string, the current
+   column is set to zero and the string is examined character by character.  If
+   the character is a tab (``\t``), one or more space characters are inserted
+   in the result until the current column is equal to the next tab position.
+   (The tab character itself is not copied.)  If the character is a newline
+   (``\n``) or return (``\r``), it is copied and the current column is reset to
+   zero.  Any other character is copied unchanged and the current column is
+   incremented by one regardless of how the character is represented when
+   printed.
+
+      >>> '01\t012\t0123\t01234'.expandtabs()
+      '01      012     0123    01234'
+      >>> '01\t012\t0123\t01234'.expandtabs(4)
+      '01  012 0123    01234'
 
 
 .. method:: str.find(sub[, start[, end]])

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list