[New-bugs-announce] [issue23775] Fix pprint of OrderedDict

Serhiy Storchaka report at bugs.python.org
Wed Mar 25 08:54:56 CET 2015


New submission from Serhiy Storchaka:

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)])

----------
assignee: serhiy.storchaka
components: Library (Lib)
files: pprint_ordered_dict.patch
keywords: patch
messages: 239234
nosy: fdrake, rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Fix pprint of OrderedDict
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file38683/pprint_ordered_dict.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23775>
_______________________________________


More information about the New-bugs-announce mailing list