Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95775
| From | Laura Creighton <lac@openend.se> |
|---|---|
| Subject | Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought |
| References | <cbcf05be-53d0-4b8b-b72b-1898cd4ad245@googlegroups.com> <mailman.129.1440902890.11709.python-list@python.org> <1daedf03-2f17-4602-8a50-eeee98a493e9@googlegroups.com> |
| Date | 2015-08-30 19:24 +0200 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1.1440955497.23514.python-list@python.org> (permalink) |
When you get TypeError: unhashable type: 'dict'
it almost always means that you are trying to use a dict as
a key for a different dict.
Python 2.7.10 (default, Jul 1 2015, 10:54:53)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> d={1:'one', 2:'two', 3:'three'}
>>> d1={1:'A', 2:'B', 3:'C'}
This doesn't work.
>>> print d1[d]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'
This does.
>>> for index in d:
... print d1[index]
...
A
B
C
HTH,
Laura
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
TypeError: unhashable type: 'dict' when attempting to hash list - advice sought kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-08-29 19:05 -0700
Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-30 03:47 +0100
Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-08-30 09:35 -0700
Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought Laura Creighton <lac@openend.se> - 2015-08-30 19:24 +0200
Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-08-30 10:34 -0700
Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought Laura Creighton <lac@openend.se> - 2015-08-30 20:20 +0200
Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-08-30 14:47 -0700
Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought MRAB <python@mrabarnett.plus.com> - 2015-08-30 03:48 +0100
Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-08-30 09:31 -0700
Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought MRAB <python@mrabarnett.plus.com> - 2015-08-30 18:15 +0100
Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-08-30 10:21 -0700
Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought Ben Finney <ben+python@benfinney.id.au> - 2015-08-30 13:04 +1000
Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-08-30 10:02 -0700
csiph-web