-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
the order of dict isn't documented in an example #133361
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
Comments
Why? They could read the rest of dict docs on same page:
|
Oh, it mentions in |
It's just after description of dict's methods.
Explain what? What's unclear in the above sentence? |
Yes, you're right. I didn't notice the indent.
I'm not sure if it is right. Some important things like the order of dict should say first. It shouldn't be after its methods. This might be more friendly for new users. |
"it" refers to the example instead of the above sentence. |
Ok. Examples here are to illustrate dict() constructor. And there are several cases, which differ by ordering of keys. I doubt that adding something does make sense here. |
Dicts became ordered (by insertion), not unordered, in 3.6/7. And it is documented: Dictionaries preserve insertion order. Note that updating a key does not affect the order. Keys added after deletion are inserted at the end." This is followed by examples and version note. Nothing more is needed. I think the following explains equality quite sufficiently, but should be moved before the example.
I am reopening to move the explanation of == before its use. |
Do you need me to create a PR to move this explanation? |
Also move up the explanation of insertion order preservation. Both paragraphs seemed out of place down where they were. --------- Co-authored-by: Terry Jan Reedy <[email protected]>
…ythonGH-133424) Also move up the explanation of insertion order preservation. Both paragraphs seemed out of place down where they were. --------- (cherry picked from commit 61ac88c) Co-authored-by: Yongzi Li <[email protected]> Co-authored-by: Terry Jan Reedy <[email protected]>
…ythonGH-133424) Also move up the explanation of insertion order preservation. Both paragraphs seemed out of place down where they were. --------- (cherry picked from commit 61ac88c) Co-authored-by: Yongzi Li <[email protected]> Co-authored-by: Terry Jan Reedy <[email protected]>
…H-133424) (#133620) gh-133361: move the explanation of dict equal before its use (GH-133424) Also move up the explanation of insertion order preservation. Both paragraphs seemed out of place down where they were. --------- (cherry picked from commit 61ac88c) Co-authored-by: Yongzi Li <[email protected]> Co-authored-by: Terry Jan Reedy <[email protected]>
…H-133424) (#133621) gh-133361: move the explanation of dict equal before its use (GH-133424) Also move up the explanation of insertion order preservation. Both paragraphs seemed out of place down where they were. --------- (cherry picked from commit 61ac88c) Co-authored-by: Yongzi Li <[email protected]> Co-authored-by: Terry Jan Reedy <[email protected]>
Documentation
I am reading the documentation of dictionary.
There is an example
For new users, they might not know that the dictionary is unorderd in 3.7+ (not everyone reads data model before reading this). So they might feel confused and think
{one: 1, two: 2}
shoudn't be equal to{two:2, one:1}
.Maybe we could link date model for explaning.
Linked PRs
The text was updated successfully, but these errors were encountered: