Message 306836 - Python tracker (original) (raw)

... 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?