[Python-ideas] Cofunctions - an enhancement to yield-from

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Aug 6 09:38:00 CEST 2010


Jack Diederich wrote:

> Or in his second suggested form to make this
>     cocall func(*args, **opts)
> equivalent to this
>     yield from func.__cocall__(*args, **opts) #  func must support __cocall__
> 
> I'm not sure if the "codef" keyword is included in the second form.

Yes, it is. An important part of it is that 'cocall' would only
be allowed inside a function defined with 'codef'. Together
with the other restrictions, this makes it impossible to mix
coroutine and non-coroutine code in invalid ways. I don't
think it's possible to get that using yield-from and decorators
(at least not without a lot of inefficient hackery).

-- 
Greg



More information about the Python-ideas mailing list