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: pprint module doesn't work well with OrderedDicts
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: duplicate
Dependencies: Superseder: general pprint rewrite
View: 7434
Assigned To: benjamin.peterson Nosy List: Matt.Barr, benjamin.peterson, cmcqueen1975, elias, eric.araujo, giampaolo.rodola, rhettinger
Priority: normal Keywords:

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:09adminsetgithub: 54801
2012-06-25 04:45:46rhettingersetstatus: open -> closed
superseder: general pprint rewrite
resolution: duplicate
2012-06-22 16:02:12Matt.Barrsetnosy: + Matt.Barr
2011-12-15 17:20:44giampaolo.rodolasetnosy: + giampaolo.rodola
2011-03-03 22:09:30cmcqueen1975setnosy: + cmcqueen1975
2010-12-16 09:13:35rhettingersetnosy: rhettinger, benjamin.peterson, eric.araujo, elias
versions: + Python 3.3, - Python 2.7
2010-12-16 09:12:56rhettingersetnosy: rhettinger, benjamin.peterson, eric.araujo, elias
messages: - msg122983
2010-12-01 08:34:26eric.araujosetsuperseder: general pprint rewrite -> (no value)
2010-12-01 05:19:27rhettingersetnosy: + rhettinger, benjamin.peterson
messages: + msg122983

assignee: benjamin.peterson
stage: resolved ->
2010-12-01 04:26:53eliassetstatus: closed -> open
resolution: duplicate -> (no value)
messages: + msg122982
2010-12-01 00:56:57eric.araujosetstatus: open -> closed

superseder: general pprint rewrite

nosy: + eric.araujo
messages: + msg122965
resolution: duplicate
stage: resolved
2010-12-01 00:20:24eliascreate