[Python-ideas] Proto-PEP on a 'yield from' statement
greg.ewing at canterbury.ac.nz
Fri Feb 13 02:15:03 CET 2009
Mike Meyer wrote:
> While you're working on that, you might consider dealing with the
> behavior of StopIteration exceptions. They're odd enough before this
> gets added; it's not at all clear to me what's going on with them
I'm not sure what I should add. The PEP is written on the
assumption that the reader understands how iterators and
generators currently work, including StopIteration. Given
that, I think it ought to be fairly clear how StopIteration
is being used in the proposal.
It's not much different from what you would do if you wanted
to iterate over an iterator manually, without using a for-loop:
x = myiter.next()
The only difference is that instead of ignoring the
StopIteration instance itself, we use it to carry the
return value of the generator.
I don't think the PEP is the right place to put tutorial
information about the current StopIteration mechanism.
More information about the Python-ideas