This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: list unhashable, can not be use as key to dict
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: gene@nlc.co.nz, ned.deily
Priority: normal Keywords:

Created on 2017-10-08 20:54 by gene@nlc.co.nz, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg303919 - (view) Author: gene@nlc.co.nz (gene@nlc.co.nz) Date: 2017-10-08 20:54
A list can no be used as the key to a dict, apparently because it is "unhashable": TypeError: unhashable type: 'list'.

The code must exist to hash object like this a tuple is hashable and can be constructed from a list.
msg303920 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2017-10-08 21:02
As documented, a dict key must be hashable and, because lists are not immutable, they are not hashable and thus can't be used as keys.  See the Python Glossary for more info.  https://docs.python.org/2/glossary.html
History
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 75911
2017-10-08 21:02:03ned.deilysetstatus: open -> closed

nosy: + ned.deily
messages: + msg303920

resolution: not a bug
stage: resolved
2017-10-08 20:54:49gene@nlc.co.nzcreate