Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb1c3329

Browse files
gh-134114: Clarify FAQ note about dictonary keys (#134118)
1 parent53da1e8 commitb1c3329

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

‎Doc/faq/design.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,12 @@ strings representing the files in the current directory. Functions which
420420
operate on this output would generally not break if you added another file or
421421
two to the directory.
422422

423-
Tuples are immutable, meaning that once a tuple has been created, you can't
424-
replace any of its elements with a new value. Lists are mutable, meaning that
425-
you can always change a list's elements. Only immutable elements can be used as
426-
dictionary keys, and hence only tuples and not lists can be used as keys.
423+
Tuples are:term:`immutable`, meaning that once a tuple has been created, you can't
424+
replace any of its elements with a new value. Lists are:term:`mutable`, meaning that
425+
you can always change a list's elements. Only:term:`hashable` objects can
426+
be used as dictionary keys. Most immutable types are hashable, which is why
427+
tuples, but not lists, can be used as keys. Note, however, that a tuple is
428+
only hashable if all of its elements are hashable.
427429

428430

429431
How are lists implemented in CPython?

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp