A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-August/068198.html below:

[Python-Dev] dict containment annoyance

[Python-Dev] dict containment annoyance [Python-Dev] dict containment annoyancetomer filiba tomerfiliba at gmail.com
Sat Aug 12 15:42:17 CEST 2006
>>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20060812/6a4c7877/attachment.html 
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4