[Python-ideas] Revised**5 PEP on yield-from

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Mar 2 05:21:51 CET 2009


Jim Jewett wrote:

> I would expect that to be interpreted as a StopIteration and handled
> gracefully. If that doesn't seem reasonable, then I wonder if the
> whole protocol is still too fragile.

I've just done what I should have done in the first place
and checked the documentation. From the Library Reference,
section 3.5, Iterator Types:

"The intention of the protocol is that once an iterator's next() method raises 
StopIteration, it will continue to do so on subsequent calls. Implementations 
that do not obey this property are deemed broken. (This constraint was added in 
Python 2.3; in Python 2.2, various iterators are broken according to this rule.)"

So according to modern-day rules at least, Jacob's example
will work fine.

-- 
Greg



More information about the Python-ideas mailing list