[Python-iterators] Re: PEP 234: Iterators
Alex Martelli
aleaxit at yahoo.com
Tue May 1 15:42:24 EDT 2001
"Guido van Rossum" <guido at digicool.com> wrote in message
news:mailman.988716782.29093.python-list at python.org...
[snip]
> iterators. E.g. here's an iterator that gives the even-numbered items
> of an argument iterator:
>
> class EvenIterator:
>
> def __init__(self, it):
> self.it = it
If I understand the PEP correctly, wouldn't
self.it = iter(it)
be better here? Idempotent if 'it' is already an iterator, good if
'it' is a sequence instead?
Alex
More information about the Python-list
mailing list