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

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Feb 13 01:42:39 CET 2009


There were some bugs in the expansion code. Here is
a corrected version.

     result = yield from iterable

expands to

     _i = iter(iterable)
     try:
         _v = yield _i.next()
         while 1:
             if hasattr(_i, 'send'):
                 _v = yield _i.send(_v)
             else:
                 _v = yield _i.next()
     except StopIteration, _e:
         _a = _e.args
         if len(_a) > 0:
             result = _a[0]
         else:
             result = None

-- 
Greg



More information about the Python-ideas mailing list