Skip to content

docs(python): clarify when tuples can be dictionary keys - #10451

Merged
jcanalesluna merged 1 commit into
nilbuild:masterfrom
Aurantium-47:codex/python-tuple-hashability
Oct 15, 2026
Merged

jcanalesluna merged 1 commit into
nilbuild:masterfrom
Aurantium-47:codex/python-tuple-hashability

Conversation

@Aurantium-47

Copy link
Copy Markdown
Contributor

The Python tuples topic currently implies that immutability makes every tuple a valid dictionary key. A tuple containing a list is a counterexample: {([1, 2],): "value"} raises TypeError: unhashable type: 'list'.

Clarify that all tuple elements must be hashable before the tuple can be used as a key. This follows the Python glossary and avoids a misleading rule for learners.

Validation: ran Python 3.12 examples with ordinary and nested hashable tuples, plus tuples containing lists directly and indirectly. Checked the Markdown structure and existing resource links; only the explanatory sentence changes.

AI assistance: OpenAI Codex assisted with investigation, editing, and verification.

@jcanalesluna
jcanalesluna merged commit 6e22fbd into nilbuild:master Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants