>>> a={1:2, 3:4}<br>>>> [] in a<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in ?<br>TypeError: list objects are unhashable<br>>>><br><br>imo, the expression should just evaluate to False instead of raising an exception.
<br>it's a question of semantics -- i asked whether the object (a list, in this case)<br>is contained in the dict. i didn't ask whether it's hashable or not. if the object is<br>unhashable, then surely it's not contained in the dict, therefore the answer is
<br>False, rather than an exception.<br><br>dict.__contains__ should just swallow these exceptions, and return False.<br><br><br>-tomer<br>