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

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


Makoto Kuwata <kwatch at gmail.com>:

>     val = yield from xs
>
> is same as::
>
>     for x in xs:
>       ret = yield x
>     val = ret
>
> Is it true? Do I understand correctly?

The return value is not one of the yielded values. Instead, it's the
value returned by the generator/coroutine.


Marko



More information about the Python-list mailing list