[Q] is 'yield from' syntax sugar for 'for'+'yield'?

Marko Rauhamaa marko at pacujo.net
Thu Aug 14 06:32:05 EDT 2014


Makoto Kuwata <kwatch at gmail.com>:

> Thank you. It seems too complicated...

I recommend you stop trying to associate the "old" yield with the "new"
yield.

Asyncio coroutines "abuse" "yield from" for a specific effect. The
classic purpose of "yield" was to spoonfeed a sequence of return values
to the caller. The coroutine meaning of "yield from" has nothing
whatsoever to do about delivering computation results; instead, it
denotes a state where a blocking operation is waited for and the control
is handed off to other activities.



Marko



More information about the Python-list mailing list