[issue10544] yield expression inside generator expression does nothing

Yury Selivanov report at bugs.python.org
Thu Nov 23 11:38:06 EST 2017


Yury Selivanov <yselivanov at gmail.com> added the comment:

> ... but [await x for x in xs] is still valid _only_ inside async def.

Yes, because it's computed right where it is defined.

a = [x for x in xs]  # `a` is a list object
a = (x for x in xs)  # `a` is a generator

Do you understand the difference?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue10544>
_______________________________________


More information about the Python-bugs-list mailing list