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

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Aug 4 01:02:15 CEST 2010


Guido van Rossum wrote:
> That could be done with a decorator, right? The decorator wraps a
> fuction in something non-callable and cocall is a function that
> unwraps it and calls it.

That would cover part of it, the part about not being able
to make a normal call to a cofunction. But it wouldn't
enforce only being able to use cocall inside a cofunction,
or remove the need for a dummy yield in a cofunction that
doesn't otherwise have any.

Also, if cocall is just a function, you would still have to
use 'yield from' on the result, so all your coroutine calls
would end up looking like

    yield from cocall(f, args)

which makes them even more verbose and thumbstickingoutish.

-- 
Greg



More information about the Python-ideas mailing list