[Python-Dev] PEP 492 vs. PEP 3152, new round

Nick Coghlan ncoghlan at gmail.com
Sat Apr 25 08:30:33 CEST 2015


On 25 April 2015 at 16:23, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> 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".)

I think "async function" is fine - "async function" is to "coroutine"
as "function" is to "callable".

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list