Skip to content

Conversation

@OTheDev
Copy link
Contributor

@OTheDev OTheDev commented Nov 5, 2025

Providing keyword arguments as in the first example only works for keys that
are valid Python identifiers. Otherwise, any valid keys can be used.
Dictionaries compare equal if and only if they have the same ``(key,
value)`` pairs (regardless of ordering). Order comparisons ('<', '<=', '>=', '>') raise
:exc:`TypeError`. To illustrate dictionary creation and equality,
the following examples all return a dictionary equal to
``{"one": 1, "two": 2, "three": 3}``::
>>> a = dict(one=1, two=2, three=3)
>>> b = {'one': 1, 'two': 2, 'three': 3}
>>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
>>> d = dict([('two', 2), ('one', 1), ('three', 3)])
>>> e = dict({'three': 3, 'one': 1, 'two': 2})
>>> f = dict({'one': 1, 'three': 3}, two=2)
>>> a == b == c == d == e == f
True
Providing keyword arguments as in the first example only works for keys that
are valid Python identifiers. Otherwise, any valid keys can be used.

The first two sentences in the snippet above are duplicated under the example.

I think it would be better if the second occurrence were removed?


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

skirpichev

This comment was marked as resolved.

@skirpichev skirpichev added needs backport to 3.14 bugs and security fixes needs backport to 3.13 bugs and security fixes labels Nov 5, 2025
@hugovk hugovk merged commit a15bd21 into python:main Dec 16, 2025
32 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Dec 16, 2025
@miss-islington-app
Copy link

Thanks @OTheDev for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 16, 2025
…honGH-141036)

(cherry picked from commit a15bd21)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 16, 2025
…honGH-141036)

(cherry picked from commit a15bd21)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Dec 16, 2025

GH-142808 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Dec 16, 2025
@bedevere-app
Copy link

bedevere-app bot commented Dec 16, 2025

GH-142809 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Dec 16, 2025
hugovk pushed a commit that referenced this pull request Dec 16, 2025
…on (GH-141036) (#142808)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
hugovk pushed a commit that referenced this pull request Dec 16, 2025
…on (GH-141036) (#142809)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
@OTheDev OTheDev deleted the remove_dupl branch December 16, 2025 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip issue skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants