[Python-ideas] Cofunctions PEP - Revision 4

Carl M. Johnson cmjohnson.mailinglist at gmail.com
Wed Aug 11 12:27:48 CEST 2010

On Tue, Aug 10, 2010 at 10:03 PM, Greg Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Here's an updated version of the PEP reflecting my
> recent suggestions on how to eliminate 'codef'.


> Also note that the final calling parentheses are mandatory, so that for
> example
> the following is invalid syntax:
> ::
>    y = cocall f     # INVALID

If this is the case, why not say "y= cocall f with (x)"  or something
like that instead of f(x)? When I see f(x), I think, "OK, so it's
going to call f with the argument x then it will do something
cocall-ish to it." But actually the reality is first it looks up the
__cocall__ on f and only then passes in the args and kwargs. Of
course, anyone who studies cocalls will learn how it really works
before they get too deep into the theory behind them, but I still
think it's kind of misleading for people new to the world of

I also suspect that Nick is right that we should probably try out
something like "y = yield from cocall(f, *args, **kwargs)" and see if
it catches on before resorting to a new keyword…

-- Carl Johnson

More information about the Python-ideas mailing list