[Python-Dev] Using async/await in place of yield expression

Yury Selivanov yselivanov.ml at gmail.com
Sun Nov 26 23:53:44 EST 2017


On Sun, Nov 26, 2017 at 11:23 PM, Caleb Hattingh
<caleb.hattingh at gmail.com> wrote:
[..]
> I'd be very grateful if anyone can point out if my understanding of the
> above is incorrect.  Private email is fine if you prefer not to post to the
> list.

It is correct.  While 'yield from coro()', where 'coro()' is an 'async
def' coroutine would make sense in some contexts, it would require
coroutines to implement the iteration protocol.  That would mean that
you could write 'for x in coro()', which is meaningless for coroutines
in all contexts.  Therefore, coroutines do not implement the iterator
protocol.

Yury


More information about the Python-Dev mailing list