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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip issue skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants