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/2000-April/003452.html below:

[Python-Dev] if key in dict?

[Python-Dev] if key in dict? [Python-Dev] if key in dict?Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Thu, 13 Apr 2000 13:06:57 +0200
now that we have the sq_contains slot, would it make
sense to add support for "key in dict" ?

after all,

    if key in dict:
        ...

is a bit more elegant than:

    if dict.has_key(key):
        ...

and much faster than:

    if key in dict.keys():
        ...

(the drawback is that once we add this, some people might ex-
pect dictionaries to behave like sequences in others ways too...)

(and yes, this might break code that looks for tp_as_sequence
before looking for tp_as_mapping.  haven't found any code like
that, but I might have missed something).

whaddyathink?

</F>




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