On Tue, Jan 23, 2001 at 03:38:39PM -0500, Eric S. Raymond wrote: > > The only change that needs to be made to support sets of immutable > > elements is to provide "in" on dictionaries. The rest is then all > > quite natural: > > dict[key] = 1 > > if key in dict: ... > > for key in dict: ... > Independently of implementation issues about sets, I think this is a > damn fine idea. +1. 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'. 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, and like American voters, the 20% middle section will change their vote each recount :-) Now, if only there was a terribly obvious way to spell it... so that it's immediately obvious which of the two you wanted.... something like, oh, I donno, this, maybe: if key in dict.keys: ... if value in dict.values: ... Ponder-ponder--Guido-should-use-the-time-machine-for-this-one!-ly y'rs, -- Thomas Wouters <thomas@xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
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