[Python-ideas] async/await in Python

Greg greg.ewing at canterbury.ac.nz
Wed Apr 22 04:07:48 CEST 2015


On 22/04/2015 4:20 a.m., Yury Selivanov wrote:
>  If we decide to implement
> coroutine-generators one day, a simple call to
> coroutine-generator should return a coroutine-generator
> object:
>
> async def foo():
>     async yield 1
>
> foo() # <- coroutine-generator object
>
> In the other hand, if you don't have an 'async yield'
> expression, then
>
> foo()
>
> would raise an error.  I'm not sure I like this duality.

If you don't like it, you could always require the call to
the async-generator to be an "await" call, even though it
can't actually suspend at that point.

-- 
Greg



More information about the Python-ideas mailing list