&gt;&gt;&gt; a={1:2, 3:4}<br>&gt;&gt;&gt; [] in a<br>Traceback (most recent call last):<br>&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in ?<br>TypeError: list objects are unhashable<br>&gt;&gt;&gt;<br><br>imo, the expression should just evaluate to False instead of raising an&nbsp; 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>