Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

bpo-30670: Add pp function to the pprint module#11769

Merged
rhettinger merged 10 commits intopython:masterfrom
remilapeyre:use-insertion-order-in-pprint
Mar 22, 2019
Merged

bpo-30670: Add pp function to the pprint module#11769
rhettinger merged 10 commits intopython:masterfrom
remilapeyre:use-insertion-order-in-pprint

Conversation

@remilapeyre
Copy link

@remilapeyreremilapeyre commentedFeb 6, 2019
edited by bedevere-bot
Loading

Add sort_dicts to pprint.PrettyPrinter, pprint.pformat and pprint.pprint

https://bugs.python.org/issue30670

Add sort_dicts to pprint.PrettyPrinter, pprint.pformat and pprint.pprint
Copy link
Contributor

@eamanueamanu left a 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 :-)

Added the *sort_dicts* parameter.


.. function:: pp(object, *args, sort_dicts=False, **kwargs)

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 ?

Copy link
Author

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.

ewjoachim reacted with thumbs up emoji

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.)

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 :-)

ewjoachim reacted with thumbs up emoji
@remilapeyre
Copy link
Author

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"
@rhettingerrhettinger merged commit96831c7 intopython:masterMar 22, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@vadmiumvadmiumvadmium left review comments

@tirkarthitirkarthitirkarthi left review comments

+3 more reviewers

@edmorleyedmorleyedmorley left review comments

@ewjoachimewjoachimewjoachim approved these changes

@eamanueamanueamanu approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

9 participants

@remilapeyre@edmorley@vadmium@ewjoachim@tirkarthi@eamanu@rhettinger@the-knights-who-say-ni@bedevere-bot

[8]ページ先頭

©2009-2026 Movatter.jp