Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.1k
Comments
bpo-30670: Add pp function to the pprint module#11769
bpo-30670: Add pp function to the pprint module#11769rhettinger merged 10 commits intopython:masterfrom
Conversation
Add sort_dicts to pprint.PrettyPrinter, pprint.pformat and pprint.pprint
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
eamanu left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I test the behavior (ubuntu 18.04) and this PR accomplish with the bpo. IMO, after solve the Travis CI error this should be ready for merge. Before be review by a core dev :-)
Uh oh!
There was an error while loading.Please reload this page.
| Added the *sort_dicts* parameter. | ||
| .. function:: pp(object, *args, sort_dicts=False, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Would it be worth explicitely saying that this is an alias of pprint() withsort_dict=False ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There is already a mention of*args and**kwargs being passed topprint andsort_dicts=False is in the signature ofpp so I don't think it is necessary.
I would like to also like to avoid giving to much details aboutpp implementation because we may change some things if another data structure of Python changes like dicts did.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
(if we were to do change what this function does, we would also change the doc, but I'm good with that.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Would it be worth explicitely saying that this is an alias of pprint() with sort_dict=False ?
At first glance I was puzzled why bothpp() andpprint() existed, and it took a moment to spot the different defaultsort_dict value - and I ended up having to confirm via source code inspection that there were no other differences between the two.
As such, the above mentioned docs would have been useful for me personally :-)
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
remilapeyre commentedFeb 11, 2019
Thanks@vadmium! |
* Add "pp" to __all__* Drop mention of alphabetical sorting. It is just plain sorting (i.e. dict with integer keys get sorted as well).* Fix spelling of "parameter"
Uh oh!
There was an error while loading.Please reload this page.
Add sort_dicts to pprint.PrettyPrinter, pprint.pformat and pprint.pprint
https://bugs.python.org/issue30670