>>> a={1:2, 3:4}
>>> [] in a
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: list objects are unhashable
>>>

imo, the _expression_ should just evaluate to False instead of raising an  exception.
it's a question of semantics -- i asked whether the object (a list, in this case)
is contained in the dict. i didn't ask whether it's hashable or not. if the object is
unhashable, then surely it's not contained in the dict, therefore the answer is
False, rather than an exception.

dict.__contains__ should just swallow these exceptions, and return False.


-tomer
_______________________________________________
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