[Tutor] Re: problems with re module

Lee Harr missive at hotmail.com
Sun Nov 16 07:58:33 EST 2003


>what does the error message mean anyway? what is a "hashable" object? THat 
>might enable me to debug my own programs better ;)


Only certain objects can be used as dictionary keys:

>>>key1 = 55
>>>key2 = 'fifty-six'
>>>key3 = ('five', 'seven')
>>>key4 = [5, 8]
>>>d = {}
>>>d[key1] = 'foo'
>>>d[key2] = 'foo'
>>>d[key3] = 'foo'
>>>d[key4] = 'foo'
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: list objects are unhashable

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail




More information about the Tutor mailing list