[New-bugs-announce] [issue34798] pprint ignores the compact parameter for dicts
Nicolas Hug
report at bugs.python.org
Tue Sep 25 10:45:41 EDT 2018
New submission from Nicolas Hug <niourf at gmail.com>:
Dict representations that exceed the line width are printed with one line per key-value pair, ignoring the compact=True parameter:
>>> pprint.pprint({i: 0 for i in range(15)}, compact=True)
{0: 0,
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
6: 0,
7: 0,
8: 0,
9: 0,
10: 0,
11: 0,
12: 0,
13: 0,
14: 0}
Expected behavior:
>>> pprint.pprint({i: 0 for i in range(15)}, compact=True)
{0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0,
12: 0, 13: 0, 14: 0}
Note that lists are correctly compacted, and that dicts that don't exceed line width are printed on a single line, regardless on the compact parameter.
I could try to work on that if needed?
----------
messages: 326358
nosy: Nicolas Hug
priority: normal
severity: normal
status: open
title: pprint ignores the compact parameter for dicts
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34798>
_______________________________________
More information about the New-bugs-announce
mailing list