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? |