[Python-Dev] Termination of two-arg iter()

Guido van Rossum guido@python.org
Sat, 13 Jul 2002 20:42:14 -0400


> > So I misremembered, and Tim didn't read the PEP closely enough. :-)
> > 
> > > I'm happy to leave this be: the docs match the implemenation, I'm
> > > sure *someone* relies on that by now, and the behavior is easy to
> > > explain as-is.
> > 
> > Hm.  Given what the PEP says, I'm ready to have this fixed (even in
> > 2.2.2).  I can't call code relying on this sane.
> 
> What about this example?
> >>> l = []
> >>> li = iter(l)
> >>> li.next()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> StopIteration
> >>> l.extend([1, 2, 3])
> >>> li.next()
> 1
> 
> does the list iterator violate the proposed behavior?

Alternatively, we could change the PEP to make this officially
undefined (or at least up to the iterator used).  I'm not sure which I
like better -- the PEP or reality. :-)

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