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.

classification
Title: textwrap: support custom tabsize
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, hynek, john.feuerstein, python-dev, rhettinger, terry.reedy
Priority: normal Keywords: needs review, patch

Created on 2011-10-11 13:05 by john.feuerstein, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
textwrap_tabsize.diff john.feuerstein, 2011-10-11 13:04 review
textwrap_tabsize_v2.diff john.feuerstein, 2011-11-07 13:58 review
Messages (8)
msg145341 - (view) Author: John Feuerstein (john.feuerstein) * Date: 2011-10-11 13:04
The textwrap module calls .expandtabs() to expand tabs to spaces.

This patch adds support for a custom tabsize, so that .expandtabs(tabsize) is called instead.

Includes test case.
msg145572 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-10-14 23:40
I am a bit surprised this was not part of the original design.
'Tabsize' make 'expand_tabs' redundant and tabsize==0 could be interpreted as expand_tabs==False. On the other hand, the meaning of 'expand_tabs' could be expanded to include the tabsize. I am almost tempted to suggest making expand_tabs > 1 be interpreted as tabsize and make expand_tabs==True(1, the current default) be interpreted as expand_tabs==8 (the new default) for back_compatibility.

Patch as is has new tests and looks good on first reading.
msg145878 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-10-18 23:53
+1
msg146764 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-11-01 09:53
Two comments:

* The new parameter to __init__ should be added at the end of the parameter list.

* A documentation update would be nice.
msg147221 - (view) Author: John Feuerstein (john.feuerstein) * Date: 2011-11-07 13:58
textwrap_tabsize_v2.diff:

* Moved the tabsize parameter to the end of the parameter list
* Added documentation update
* Made the test case more obvious
msg159689 - (view) Author: Hynek Schlawack (hynek) * (Python committer) Date: 2012-04-30 11:22
The code LGTM, the documentation lacks `versionchanged` tag though. Would you mind adding it?
msg161110 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-05-19 11:49
New changeset d38e821c1b80 by Hynek Schlawack in branch 'default':
#13152: Allow to specify a custom tabsize for expanding tabs in textwrap
http://hg.python.org/cpython/rev/d38e821c1b80
msg161111 - (view) Author: Hynek Schlawack (hynek) * (Python committer) Date: 2012-05-19 11:50
I've added it myself and committed your code – thank you for your contribution John!
History
Date User Action Args
2022-04-11 14:57:22adminsetgithub: 57361
2012-05-19 11:50:52hyneksetstatus: open -> closed
resolution: fixed
messages: + msg161111

stage: patch review -> resolved
2012-05-19 11:49:06python-devsetnosy: + python-dev
messages: + msg161110
2012-04-30 11:22:08hyneksetnosy: + hynek
messages: + msg159689
2011-11-07 13:58:37john.feuersteinsetfiles: + textwrap_tabsize_v2.diff

messages: + msg147221
2011-11-01 09:53:58georg.brandlsetmessages: + msg146764
2011-10-18 23:53:58rhettingersetnosy: + rhettinger
messages: + msg145878
2011-10-14 23:40:11terry.reedysetnosy: + terry.reedy
messages: + msg145572
2011-10-11 13:13:54ezio.melottisetkeywords: + needs review
nosy: + georg.brandl

stage: patch review
2011-10-11 13:05:00john.feuersteincreate