Path: csiph.com!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; "subject:' ": 0.07; 'cc:addr:python-list': 0.09; 'dict': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'type:': 0.09; 'typeerror:': 0.09; 'python': 0.10; 'index': 0.13; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'message-id:@fido.openend.se': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'subject:type': 0.16; 'subject:when': 0.16; 'unhashable': 0.16; 'laura': 0.18; '>>>': 0.20; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; '"",': 0.22; 'trying': 0.22; '(most': 0.24; "doesn't": 0.26; 'subject:list': 0.26; 'received:se': 0.29; 'cc:no real name:2**1': 0.29; 'print': 0.30; 'work.': 0.30; 'traceback': 0.33; 'file': 0.34; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'means': 0.39; 'header:Message- Id:1': 0.61; 'more': 0.63; 'different': 0.63; 'jul': 0.72; 'dict.': 0.84; 'header:In-reply-to:1': 0.84 To: kbtyo cc: python-list@python.org, lac@openend.se From: Laura Creighton Subject: Re: TypeError: unhashable type: 'dict' when attempting to hash list - advice sought In-reply-to: <1daedf03-2f17-4602-8a50-eeee98a493e9@googlegroups.com> References: <1daedf03-2f17-4602-8a50-eeee98a493e9@googlegroups.com> Comments: In-reply-to kbtyo message dated "Sun, 30 Aug 2015 09:35:20 -0700." MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27924.1440955489.1@fido> Date: Sun, 30 Aug 2015 19:24:49 +0200 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [89.233.217.130]); Sun, 30 Aug 2015 19:24:51 +0200 (CEST) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1440955497 news.xs4all.nl 23833 [2001:888:2000:d::a6]:33792 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95775 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 "", line 1, in TypeError: unhashable type: 'dict' This does. >>> for index in d: ... print d1[index] ... A B C HTH, Laura