Issue 6945: pprint.pprint does not pprint unsortable dicts in Python 3 (original) (raw)

Issue6945

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.

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/51194

classification

Title: pprint.pprint does not pprint unsortable dicts in Python 3
Type: Stage:
Components: Versions: Python 3.1

process

Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: aronacher, georg.brandl, pitrou
Priority: high Keywords:

Created on 2009-09-19 09:26 by aronacher, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg92862 - (view) Author: Armin Ronacher (aronacher) * (Python committer) Date: 2009-09-19 09:26
Currently pprint does not work on dicts it cannot sort. Because in Python 3 sorted(x.items()) is no longer guaranteed to work a new sorting solution has to be found.
msg92868 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-09-19 13:11
A simple fix is to use key=lambda x: (id(type(x)), x). However, that obviously doesn't work with values of different, but orderable types. At the moment, I don't see how the Python 2 sort could be implemented without a cmp() argument to sorted().
msg92901 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-09-20 17:09
Is it the same as #3976?
msg92902 - (view) Author: Armin Ronacher (aronacher) * (Python committer) Date: 2009-09-20 17:10
Yes. Appears to be related.
msg92903 - (view) Author: Armin Ronacher (aronacher) * (Python committer) Date: 2009-09-20 17:10
Duplicate of #3976
History
Date User Action Args
2022-04-11 14:56:53 admin set github: 51194
2009-09-20 17:11:13 aronacher set status: open -> closed
2009-09-20 17:10:54 aronacher set resolution: duplicatemessages: +
2009-09-20 17:10:20 aronacher set messages: +
2009-09-20 17:09:14 pitrou set nosy: + pitroumessages: +
2009-09-19 13:11:49 georg.brandl set priority: highnosy: + georg.brandlmessages: +
2009-09-19 09:26:58 aronacher create

Supported by The Python Software Foundation,
Powered by Roundup

Copyright © 1990-2022, Python Software Foundation
Legal Statements