Skip to content
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

gh-110383: Add documentation entry for sorted(d) #112777

Closed
wants to merge 2 commits into from

Conversation

shenanigansd
Copy link
Contributor

@shenanigansd shenanigansd commented Dec 5, 2023

Continues #110383
Originally reported in https://mail.python.org/archives/list/docs@python.org/thread/ZEDPZHRVGLYR4ZFZ5I3NBWVMHMX4WPGW/ (3rd list item)

Add a documentation entry for sorted(d) to clarify that it returns the sorted keys and not the dict itself.


📚 Documentation preview 📚: https://cpython-previews--112777.org.readthedocs.build/

@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news awaiting review labels Dec 5, 2023
@rhettinger
Copy link
Contributor

Thank for you the suggestion but we should decline. Mostly, we try to avoid this kind of tight coupling of documentation between different parts of the language. Tools like sorted, reversed, and enumerate are ways that any iterable (or sequence) can be returned. There is nothing specific to dictionaries.

If this comes up again, we could consider an FAQ entry or an addition to the looping idioms section of the tutorial, but this edit to the detailed spec for dicts is the wrong place to do it (and not at all discoverable by beginners).

One other thought is that this hasn't come up before and the underlying report wasn't from a beginner; instead, it was an unsubstantiated suggestion that somewhere someone might someday have a moment of confusion.

@rhettinger rhettinger closed this Dec 16, 2023
@shenanigansd shenanigansd deleted the patch-1 branch December 16, 2023 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants