[Tutor] how to understand unhashable type: 'list'
lina.lastname at gmail.com
Thu Nov 17 15:32:56 CET 2011
Thanks for all. Everything new to me is so amazing.
Well, still a remaining question, how to sort based on the value of the key.
Actually I googled hours ago, wanna see more ways of doing it.
> On 17 November 2011 14:04, lina <lina.lastname at gmail.com> wrote:
>> >> Traceback (most recent call last):
>> >> File "<pyshell#292>", line 1, in <module>
>> >> weight[list1]=1
>> >> TypeError: unhashable type: 'list'
>> > You are trying to store a list as a key inside a dict. This cannot be
>> > done
>> > because lists (like all mutable types) can't be hashed.
>> I checked online dictionary, still confused about hashed. is it equal
>> to mix together or mess together?
> No.... you need to think programming/computer science where hash/hashing has
> a different meaning. See wikipedia:
> Also see the description for "hashable" in the Python glossary:
> Basically hashing is a way to convert something (often a string) into an
> identifying number (not neccesarily but usually unique) in order to use this
> number as a token for the original thing. Aside, you can infer that that
> because the "dict" code complains about hashing implies that dicts
> themselves are essentially implemented as hash tables... ;)
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
More information about the Tutor