homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bethard
Recipients
Date 2005年11月19日.19:02:09
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
I'm not sure whether this is a documentation bug or a
code bug, but textwrap.dedent() expands tabs (and
AFAICT doesn't give the user any way of stopping this):
py> def test():
... x = ('abcd efgh\n'
... 'ijkl mnop\n')
... y = textwrap.dedent('''\
... abcd efgh
... ijkl mnop
... ''')
... return x, y
...
py> test()
('abcd\tefgh\nijkl\tmnop\n', 'abcd efgh\nijkl 
mnop\n') 
Looking at the code, I can see the culprit is the first
line:
lines = text.expandtabs().split('\n')
If this is the intended behavior, I think the first
sentence in the documentation[1] should be replaced with:
"""
Replace all tabs in string with spaces as per
str.expandtabs() and then remove any whitespace that
can be uniformly removed from the left of every line in
text.
"""
and (I guess this part is an RFE) textwrap.dedent()
should gain an optional expandtabs= keyword argument to
disable this behavior.
If it's not the intended behavior, I'd love to see that
.expandtabs() call removed.
[1]http://docs.python.org/lib/module-textwrap.html 
History
Date User Action Args
2007年08月23日 14:36:19adminlinkissue1361643 messages
2007年08月23日 14:36:19admincreate

AltStyle によって変換されたページ (->オリジナル) /