In python 3.3 I can do the following
def _gen(): for i in range(3): yield i def gen(): yield from _gen() for i in gen(): print(i) >>> 0 >>> 1 >>> 2 Can I do the same within a python 3.6 asyncio coroutine? (Warning, contrived example)
async def _gen(): for i in range(3): yield await get_num(i) # get_num is a coroutine async def gen(): yield from _gen() # Syntax error! for i in gen(): print(i) I need to define gen as
async def gen(): async for i in _gen(): yield i But it seems there should be a way to delegate to the other coroutine as we could with yield from