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/2001-January/012106.html below:

[Python-Dev] Re: Sets: elt in dict, lst.include

[Python-Dev] Re: Sets: elt in dict, lst.includeKa-Ping Yee ping@lfw.org
Tue, 23 Jan 2001 19:29:24 -0800 (PST)
I wrote:
> The only change that needs to be made to support sets of immutable
> elements is to provide "in" on dictionaries.

Thomas Wouters wrote:
> It's come up before. The problem with it is that it's not quite obvious
> whether it is 'if key in dict' or 'if value in dict'.

Yes, and i've seen this objection before, and i think it's silly.

> Sure, from the above
> example it's obvious what you *expect*, but I suspect that 'for x in dict'
> will result in a 40/60 split in expectations,

No way... it's at least 90/10.

How often do you write 'dict.has_key(x)'?          (std lib says: 206)
How often do you write 'for x in dict.keys()'?     (std lib says: 49)

How often do you write 'x in dict.values()'?       (std lib says: 0)
How often do you write 'for x in dict.values()'?   (std lib says: 3)

I rest my case.


-- ?!ng




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