mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-77753: Add example for values that compare equal in stdtypes (#98497)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
4196ee5c8b
commit
0ca6a4d640
1 changed files with 3 additions and 5 deletions
|
@ -4370,11 +4370,9 @@ type, the :dfn:`dictionary`. (For other containers see the built-in
|
||||||
A dictionary's keys are *almost* arbitrary values. Values that are not
|
A dictionary's keys are *almost* arbitrary values. Values that are not
|
||||||
:term:`hashable`, that is, values containing lists, dictionaries or other
|
:term:`hashable`, that is, values containing lists, dictionaries or other
|
||||||
mutable types (that are compared by value rather than by object identity) may
|
mutable types (that are compared by value rather than by object identity) may
|
||||||
not be used as keys. Numeric types used for keys obey the normal rules for
|
not be used as keys.
|
||||||
numeric comparison: if two numbers compare equal (such as ``1`` and ``1.0``)
|
Values that compare equal (such as ``1``, ``1.0``, and ``True``)
|
||||||
then they can be used interchangeably to index the same dictionary entry. (Note
|
can be used interchangeably to index the same dictionary entry.
|
||||||
however, that since computers store floating-point numbers as approximations it
|
|
||||||
is usually unwise to use them as dictionary keys.)
|
|
||||||
|
|
||||||
.. class:: dict(**kwargs)
|
.. class:: dict(**kwargs)
|
||||||
dict(mapping, **kwargs)
|
dict(mapping, **kwargs)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue