New submission from Chris Jerdonek: While working on issue 1859, I noticed that textwrap.wrap()'s tab expansion does not seem to behave sensibly.
In particular, the documentation says, "If expand_tabs is true, then all tab characters in text will be expanded to zero or more spaces, *depending on the current column* and the given tab size." The problem is that tab expansion is done as the first stage (and in particular, before wrapping), which means that "the current column" is no longer current after wrapping. This leads to results like-- from textwrap import wrap text = ("a\tb " "a\tb") lines = wrap(text, width=5, tabsize=4) for line in lines: print(repr(line)) Output: 'a b' 'a b' One would expect tab expansion to occur after (or while) wrapping, so that tab stops line up in the wrapped output. ---------- messages: 166815 nosy: cjerdonek priority: normal severity: normal status: open title: textwrap.wrap expand_tabs does not behave as expected _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15492> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com