Python aiter() built-in function

From the Python 3 documentation

Return an asynchronous iterator for an asynchronous iterable. Equivalent to calling x.__aiter__(). aiter() is an async equivalent of iter()


>>> async def aitersync(iterable):
...    results = []
...    async for x in aiter(iterable):
...        results.append(x)
...    return iter(results)

Subscribe to

Join 10.900+ Python developers in a two times a month and bullshit free publication , full of interesting, relevant links.