[Python-ideas] Proto-PEP on a 'yield from' statement

Raymond Hettinger python at rcn.com
Fri Feb 13 04:08:41 CET 2009

>I would think that in addition to forwarding send values to the 
> subgenerator, that throw exceptions sent to the delegating generator 
> also be forwarded to the subgenerator.  If the subgenerator does not 
> handle the exception, then it should be re-raised in the delegating 
> generator.  Also, the subgenerator close method should be called by the 
> delegating generator.  

I recommend dropping the notion of forwarding from the proposal.
The idea is use-case challenged, complicated, and should not be
hidden behind new syntax.

Would hate for this to become a trojan horse proposal
when most folks just want a fast iterator pass-through mechasism:

def threesomes(vars)
   for var in vars:
        yield from itertools.repeat(var, n)


More information about the Python-ideas mailing list