Issue 10592: pprint module doesn't work well with OrderedDicts (original) (raw)

Issue10592

Created on 2010-12-01 00:20 by elias, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg122963 - (view) Author: Elias Zamaria (elias) * Date: 2010-12-01 00:20
If I try to pretty-print an ordered dictionary, it doesn't show nicely. Instead of having each key-value pair on its own line, the whole thing shows up on one long line, which wraps many times and is hard to read. I can provide an example if you want. Is there a way to make it print nicely, like the old unordered dictionaries?
msg122965 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-12-01 00:56
I’m afraid there is no way, but a robust solution will be designed. See #7434.
msg122982 - (view) Author: Elias Zamaria (elias) * Date: 2010-12-01 04:26
I forgot to mention, someone came up with this suggestion (http://stackoverflow.com/questions/4301069/any-way-to-properly-pretty-print-ordered-dictionaries-in-python/4303996#4303996). It is not the best, but the output is better than how it is now. Can it be somehow integrated into the PrettyPrinter.format method?
History
Date User Action Args
2022-04-11 14:57:09 admin set github: 54801
2012-06-25 04:45:46 rhettinger set status: open -> closedsuperseder: general pprint rewriteresolution: duplicate
2012-06-22 16:02:12 Matt.Barr set nosy: + Matt.Barr
2011-12-15 17:20:44 giampaolo.rodola set nosy: + giampaolo.rodola
2011-03-03 22:09:30 cmcqueen1975 set nosy: + cmcqueen1975
2010-12-16 09:13:35 rhettinger set nosy:rhettinger, benjamin.peterson, eric.araujo, eliasversions: + Python 3.3, - Python 2.7
2010-12-16 09:12:56 rhettinger set nosy:rhettinger, benjamin.peterson, eric.araujo, eliasmessages: -
2010-12-01 08:34:26 eric.araujo set superseder: general pprint rewrite -> (no value)
2010-12-01 05:19:27 rhettinger set nosy: + rhettinger, benjamin.petersonmessages: + assignee: benjamin.petersonstage: resolved ->
2010-12-01 04:26:53 elias set status: closed -> openresolution: duplicate -> (no value)messages: +
2010-12-01 00:56:57 eric.araujo set status: open -> closedsuperseder: general pprint rewritenosy: + eric.araujomessages: + resolution: duplicatestage: resolved
2010-12-01 00:20:24 elias create