[issue17670] expandtabs() weirdness

Ned Deily report at bugs.python.org
Tue Apr 9 02:49:53 CEST 2013


Ned Deily added the comment:

Yes, the behavior is by design.  I think you are misunderstanding how exandtabs() works.  The "tabsize" argument indicates the number of columns each tab position occupies.  So, with a tabsize of 4, the tab positions occur every four columns; the tab positions are where the characters immediately following the tab character start.  Perhaps this example will make the behavior clearer:

>>> '1\t2'.expandtabs(4)
'1   2'
>>> '12\t3'.expandtabs(4)
'12  3'
>>> '123\t4'.expandtabs(4)
'123 4'

----------
nosy: +ned.deily
resolution:  -> works for me
stage:  -> committed/rejected
status: open -> closed
title: expandabs() weirdness -> expandtabs() weirdness

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


More information about the Python-bugs-list mailing list