Best solution (Re: Discussion about PEP 234: iterators)

Steve Purcell stephen_purcell at
Tue Feb 20 02:57:34 EST 2001

Huaiyu Zhu wrote:
> >- make 'dict.keys' return the proxy object, which is
> >  callable.  Make proxy.__call__() return an actual
> >  list from the proxy so dict.keys() works as before.
> >  So cute I'm ashamed I even thought of it.
> What a bright idea!  This is the best solution I've seen so far.  I'm
> surprised no one has commented on this yet.  So let me spell it out to
> generate more interest.
> With this proposal, all of these work as expected
> for k in dict.keys:
> for k, v in dict.items:
> for v in dict.values:
> without creating extra list.  And all of these work as expected
> if k in dict.keys:
> if k, v in dict.items:
> if v in dict.values:

I love it. Where do I vote? :-)

This is *much* nicer looking than the peculiar new ':' syntax.


Steve Purcell, Pythangelist
Get testing at
Get servlets at
"Even snakes are afraid of snakes." -- Steven Wright

More information about the Python-list mailing list