Hello, recently, I have discovered Python's coroutines and enjoyed the whole asyncio system a lot. But I ask you to make me understand one thing in Python's coroutines design: why do we have to use "await" (or "yield from") in coroutines? Why can coroutines etc. not be used _from_coroutines_ (designated by 'async def') by a simple call-like syntax (i.e. without the 'await' keyword)? The same for "await with" and "await from". At most places a coroutine is referenced from another coroutine, it is referenced using "await". Couldn't it be avoided at theese places? This way, one would not have to differentiate between function and coroutine "call" from within a coroutine...
Current syntax: async def work(x): await asyncio.sleep(x) def main(x): loop.run_until_complete(work(x)) Proposed syntax: async def work(x): asyncio.sleep(x) # compiler "adds" 'await' automatically when in 'async def' def main(x): loop.run_until_complete(work(x)) # compiler leaves as is when in 'def' Historically, generators were defined by using keyword 'yield' inside its definition. We now have explicit syntax with keyword 'async' so why should we use yet the additional keyword 'await'? I tried to show (a minor) example which would need the "leave as is" behavior inside 'async def', but I haven't found such a coroutine refence in examples. Should it be needed (please, tell me), then it requires a special syntax (at least for arguments - without arguments one can leave out the parentheses). Kouli -- https://mail.python.org/mailman/listinfo/python-list