[New-bugs-announce] [issue29089] Python 2 dictionary keys described incorrectly

Xezlec report at bugs.python.org
Tue Dec 27 16:27:05 EST 2016


New submission from Xezlec:

In section 5.5 on the page https://docs.python.org/2/tutorial/datastructures.html#dictionaries the requirements given for dictionary keys are not correct.

Specifically, it is claimed that only immutable objects (and tuples containing only immutable objects) may be used as keys.  This is false, as user-defined mutable objects may be used as keys.  I suggest rewording along these lines:

"Only user-defined objects and immutable built-in types may be used as keys.  Although allowed, it is bad practice to use a mutable user-defined object as a key when equality is determined in any way other than identity (the default)."

----------
assignee: docs at python
components: Documentation
messages: 284135
nosy: Xezlec, docs at python
priority: normal
severity: normal
status: open
title: Python 2 dictionary keys described incorrectly
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29089>
_______________________________________


More information about the New-bugs-announce mailing list