[Python-Dev] Re: Sets: elt in dict, lst.include - really begs for a PEP

Moshe Zadka moshez@zadka.site.co.il
Wed, 31 Jan 2001 12:14:49 +0200 (IST)

On Wed, 31 Jan 2001 01:47:10 -0800 (PST), Ka-Ping Yee <ping@lfw.org> wrote:

> Okay, i have written a draft PEP that tries to combine the
> "elt in dict", custom iterator, and "for k:v" issues into a
> coherent proposal.  Have a look:
>     http://www.lfw.org/python/pep-iterators.txt
>     http://www.lfw.org/python/pep-iterators.html

Er....one problem with first reading: you forgot to mention in the
while loop description that 'else:' would be executed if the exception
is raised, so the 'break' is a pseudo-break'.

Basic response: I *love* the iter(), sq_iter and __iter__ parts.
I tremble at seeing the rest.
Why not add a method to dictionaries .iteritems() and do

for (k, v) in dict.iteritems():

(dict.iteritems() would return an an iterator to the items)

Moshe Zadka <sig@zadka.site.co.il>
This is a signature anti-virus. 
Please stop the spread of signature viruses!
Fingerprint: 4BD1 7705 EEC0 260A 7F21  4817 C7FC A636 46D0 1BD6