Greg Ewing wrote:
> Guido van Rossum wrote:
>> try:
>>   hash(x)
>> except TypeError:
>>   # apparently x is not hashable
>>
>> then you're also swallowing any type errors in the computation of a
>> legitimate hash function.
> 
> Maybe it would help if there were a specific exception,
> such as NotHashableError, that hash functions were
> expected to raise in this situation instead of a
> generic TypeError.

I was going to suggest this, but then I realized that what is really 
desirable is a check for hashability. But since hashability is a deep 
property, it is difficult to check for.. seems like an very specific 
exception type would be a simple solution. FYI, I appreciate that 
swallowing all TypeErrors is bad form, so it would be nice if it was 
possible to differentiate ;-)

Some brief googling on the subject yield a discussion on py3k about this 
very subject.

http://mail.python.org/pipermail/python-3000/2006-July/002697.html

Guido wrote:
 > Personally, I'm not sure this problem needs solving; I don't recall
 > ever needing to know whether something is hashable. So perhaps it's of
 > purely theoretical importance? That would suit me fine given the above
 > dilemma...
 >
 > --Guido


-- 
Scott Dial
[EMAIL PROTECTED]
[EMAIL PROTECTED]
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to