-
-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pprint does not keep the order of dict keys #115985
Comments
This is the expected behaviour, and is not a bug. From the documentation,
As a side note, it's always good to check the documentation to see what the expected behaviour is before reporting something as a bug. (Please don't take that as a criticism of this bug report though; it's appreciated that you took the time out of your day to help out the Python project.) |
Thanks for the report! As @kotnen says, this is longstanding and intentional behaviour that we wouldn't be able to easily change without breaking backwards compatibility. However, I think there's a number of documentation improvements we could make here to call out the default behaviour of |
Hi @kotnen , I should have checked the documentation before opening the issue... Thanks for you feedback! |
pprint predate ordered keys by at least a decade. Sorting keys was then part of the expectation of 'pretty'. It also enabled a predictable output string for doctests. |
Bug report
Bug description:
As in the title:
gives the following:
CPython versions tested on:
3.12
Operating systems tested on:
Windows
The text was updated successfully, but these errors were encountered: