[Python-Dev] PEP 380 (yield from a subgenerator) comments

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Mar 23 01:34:26 CET 2009


Antoine Pitrou wrote:

> If it's really enough to understand and debug all corner cases of using "yield
> from", then fair enough.

In the case where the subiterator is another generator and
isn't shared, it's intended to be a precise and complete
specification. That covers the vast majority of the use
cases I have in mind.

Most of the complexities arise from trying to pin down
what happens when the subiterator isn't a generator, or
is being shared by other code. I don't know how the
specification could be made any simpler for those cases
while still being complete.

Even so, the intention is that if you understand the
semantics in the generator case, the behaviour in the
other cases should be something reasonable and
unsurprising. I certainly don't expect users to memorize
either the expansion or the full text of the English
explanation.

-- 
Greg


More information about the Python-Dev mailing list