Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textwrap: support custom tabsize #57361

Closed
johnfeuerstein mannequin opened this issue Oct 11, 2011 · 8 comments
Closed

textwrap: support custom tabsize #57361

johnfeuerstein mannequin opened this issue Oct 11, 2011 · 8 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@johnfeuerstein
Copy link
Mannequin

johnfeuerstein mannequin commented Oct 11, 2011

BPO 13152
Nosy @birkenfeld, @rhettinger, @terryjreedy, @hynek
Files
  • textwrap_tabsize.diff
  • textwrap_tabsize_v2.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2012-05-19.11:50:52.783>
    created_at = <Date 2011-10-11.13:05:00.070>
    labels = ['type-feature', 'library']
    title = 'textwrap: support custom tabsize'
    updated_at = <Date 2012-05-19.11:50:52.782>
    user = 'https://bugs.python.org/johnfeuerstein'

    bugs.python.org fields:

    activity = <Date 2012-05-19.11:50:52.782>
    actor = 'hynek'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-05-19.11:50:52.783>
    closer = 'hynek'
    components = ['Library (Lib)']
    creation = <Date 2011-10-11.13:05:00.070>
    creator = 'john.feuerstein'
    dependencies = []
    files = ['23376', '23624']
    hgrepos = []
    issue_num = 13152
    keywords = ['patch', 'needs review']
    message_count = 8.0
    messages = ['145341', '145572', '145878', '146764', '147221', '159689', '161110', '161111']
    nosy_count = 6.0
    nosy_names = ['georg.brandl', 'rhettinger', 'terry.reedy', 'python-dev', 'hynek', 'john.feuerstein']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue13152'
    versions = ['Python 3.3']

    @johnfeuerstein
    Copy link
    Mannequin Author

    johnfeuerstein mannequin commented Oct 11, 2011

    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.

    @johnfeuerstein johnfeuerstein mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Oct 11, 2011
    @terryjreedy
    Copy link
    Member

    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.

    @rhettinger
    Copy link
    Contributor

    +1

    @birkenfeld
    Copy link
    Member

    Two comments:

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

    • A documentation update would be nice.

    @johnfeuerstein
    Copy link
    Mannequin Author

    johnfeuerstein mannequin commented Nov 7, 2011

    textwrap_tabsize_v2.diff:

    • Moved the tabsize parameter to the end of the parameter list
    • Added documentation update
    • Made the test case more obvious

    @hynek
    Copy link
    Member

    hynek commented Apr 30, 2012

    The code LGTM, the documentation lacks versionchanged tag though. Would you mind adding it?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 19, 2012

    New changeset d38e821c1b80 by Hynek Schlawack in branch 'default':
    bpo-13152: Allow to specify a custom tabsize for expanding tabs in textwrap
    http://hg.python.org/cpython/rev/d38e821c1b80

    @hynek
    Copy link
    Member

    hynek commented May 19, 2012

    I've added it myself and committed your code – thank you for your contribution John!

    @hynek hynek closed this as completed May 19, 2012
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants