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

Fix pprint of OrderedDict #67963

Closed
serhiy-storchaka opened this issue Mar 25, 2015 · 4 comments
Closed

Fix pprint of OrderedDict #67963

serhiy-storchaka opened this issue Mar 25, 2015 · 4 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 23775
Nosy @freddrake, @rhettinger, @berkerpeksag, @serhiy-storchaka
Files
  • pprint_ordered_dict.patch
  • 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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2015-03-26.06:57:06.939>
    created_at = <Date 2015-03-25.07:54:56.505>
    labels = ['type-feature', 'library']
    title = 'Fix pprint of OrderedDict'
    updated_at = <Date 2015-03-26.06:57:06.937>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-03-26.06:57:06.937>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-03-26.06:57:06.939>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2015-03-25.07:54:56.505>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['38683']
    hgrepos = []
    issue_num = 23775
    keywords = ['patch']
    message_count = 4.0
    messages = ['239234', '239285', '239308', '239309']
    nosy_count = 6.0
    nosy_names = ['fdrake', 'rhettinger', 'python-dev', 'berker.peksag', 'serhiy.storchaka', 'alexei.romanov']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue23775'
    versions = ['Python 3.5']

    @serhiy-storchaka
    Copy link
    Member Author

    Currently pprint prints the repr of OrderedDict if it fits in one line, and prints the repr of dict if it is wrapped.

    >>> import collections, pprint
    >>> pprint.pprint(collections.OrderedDict([(4, 3), (2, 1)]))
    OrderedDict([(4, 3), (2, 1)])
    >>> pprint.pprint(collections.OrderedDict([(4, 3), (2, 1)]), width=25)
    {4: 3,
     2: 1}

    Proposed patch makes pprint always produce an output compatible with OrderedDict's repr.

    >>> pprint.pprint(collections.OrderedDict([(4, 3), (2, 1)]), width=25)
    OrderedDict([(4, 3),
                 (2, 1)])

    @serhiy-storchaka serhiy-storchaka self-assigned this Mar 25, 2015
    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Mar 25, 2015
    @berkerpeksag
    Copy link
    Member

    LGTM. Added minor comments on Rietveld.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 26, 2015

    New changeset afc21da5935f by Serhiy Storchaka in branch 'default':
    Issue bpo-23775: pprint() of OrderedDict now outputs the same representation
    https://hg.python.org/cpython/rev/afc21da5935f

    @serhiy-storchaka
    Copy link
    Member Author

    Thank you for your review Berker.

    @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

    2 participants