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.
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.
textwrap_tabsize_v2.diff: * Moved the tabsize parameter to the end of the parameter list * Added documentation update * Made the test case more obvious