[issue17670] Improve str.expandtabs() doc

Ned Deily report at bugs.python.org
Mon Apr 15 23:02:03 CEST 2013


Ned Deily added the comment:

Thanks for the suggested.  Here's a revised wording and a slightly more legible example:


   Return a copy of the string where all tab characters are replaced by zero or
   more spaces, depending on the current tab column and the given tab size.
   Starting at the first character of the string, the tab column is set to
   zero.  Whenever a tab character (``\t``) is encountered, space characters
   are inserted as needed until the next tab position is reached and the tab
   column is set to that tab position; the tab character itself is not copied.
   Whenever a newline character (``\n`` or ``\r``) is encountered, it is copied
   and the tab column is reset to zero.  Any other character is copied unchanged
   and the tab column is incremented by one regardless of how it may be
   represented when printed.  If *tabsize* is not given, a tab size of 8
   characters is assumed.

      >>> '012\t4\t89'.expandtabs(4)
      '012 4   89'

----------
Added file: http://bugs.python.org/file29875/issue17670_doc_rev_1.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17670>
_______________________________________


More information about the Python-bugs-list mailing list