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: Fix pprint of OrderedDict
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: alexei.romanov, berker.peksag, fdrake, python-dev, rhettinger, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-03-25 07:54 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pprint_ordered_dict.patch serhiy.storchaka, 2015-03-25 07:54 review
Messages (4)
msg239234 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-03-25 07:54
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)])
msg239285 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-03-25 22:54
LGTM. Added minor comments on Rietveld.
msg239308 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-03-26 06:52
New changeset afc21da5935f by Serhiy Storchaka in branch 'default':
Issue #23775: pprint() of OrderedDict now outputs the same representation
https://hg.python.org/cpython/rev/afc21da5935f
msg239309 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-03-26 06:57
Thank you for your review Berker.
History
Date User Action Args
2022-04-11 14:58:14adminsetgithub: 67963
2015-03-26 06:57:06serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg239309

stage: commit review -> resolved
2015-03-26 06:52:13python-devsetnosy: + python-dev
messages: + msg239308
2015-03-25 22:54:40berker.peksagsetnosy: + berker.peksag

messages: + msg239285
stage: patch review -> commit review
2015-03-25 10:26:10alexei.romanovsetnosy: + alexei.romanov
2015-03-25 07:54:56serhiy.storchakacreate