[Python-Dev] PEP 492 vs. PEP 3152, new round (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Apr 25 08:23:20 CEST 2015


Guido van Rossum wrote:

Sorry, when I wrote "future" (lower-case 'f') I really meant what Yury calls awaitable. That's either a coroutine or something with an await emthod.

But how is an awaitable supposed to raise StopIteration if it's implemented by a generator or async def[*] function? Those things use StopIteration to wrap return values.

I like the idea of allowing StopIteration to be raised in an async def function and wrapping it somehow. I'd add that it could also be unwrapped automatically when it emerges from 'await', so that code manually invoking anext can catch StopIteration as usual.

I don't think this could conflict with any existing uses of StopIteration, since raising it inside generators is currently forbidden.

[*] I'm still struggling with what to call those things. Calling them just "coroutines" seems far too ambiguous. (There should be a Zen item something along the lines of "If you can't think of a concise and unambiguous name for it, it's probably a bad idea".)

-- Greg



More information about the Python-Dev mailing list