How to determine if something is hashable?
Andrew Post
apost at cbmi.upmc.edu
Mon Jun 25 13:48:55 EDT 2001
Hello,
I want to write a function that takes a list of keys and a list of
values and returns a hash. I want to test, however, that all of the
items in the list of keys are hashable. How do I do this? The only way
that I've come up with so far is to do:
try:
myDict[ keyList[ i ] ] = valList[ i ]
except (TypeError):
print keyList[ i ], 'is not hashable'
TypeError isn't specific to finding a non-hashable key, though, right?
Thanks,
Andrew Post
More information about the Python-list
mailing list