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

Guido van Rossum guido@digicool.com
Tue, 23 Jan 2001 23:20:56 -0500


> > >     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,

No chance of a time-machine escape, but I *can* say that I agree that
Ping's proposal makes a lot of sense.  This is a reversal of my
previous opinion on this matter.  (Take note -- those don't happen
very often! :-)

First to submit a working patch gets a free copy of 2.1a2 and
subsequent releases,

--Guido van Rossum (home page: http://www.python.org/~guido/)