On Sun, Jun 14, 2020 at 9:54 AM Greg Ewing greg.ewing@canterbury.ac.nz wrote:
But this would require reading the programmer's mind, because it's quite legitimate to create an iterator and keep it around to be yielded from later. Likewise, it's legitimate to create an awaitable object and then await it later.
(Personally I think it *shouldn't* be legitimate to do that in the case of await, but Guido thinks otherwise, so it is the way it is.)
If it isn't, then how do you start multiple tasks in parallel?
async def get_thing(id): await spam(id) await ham(id) return await internet()
needed_things = [53, 110, 587] tasks = [get_thing(id) for id in needed_things] # ... now what?
Somehow you need to have three tasks run concurrently, and if you weren't allowed to create an awaitable without immediately awaiting it, how would you do that?
ChrisA