Dec-08-2019, 09:30 PM
You can replace this code:
class Aiter : def __init__(self, iterable): self.iter_ = iter(iterable) async def __aiter__(self): return self async def __anext__(self): await asyncio .sleep(0) try: object = next(self.iter_) except StopIteration: raise StopAsyncIteration # :-) PEP492 - "To stop iteration __anext__ must raise a StopAsyncIteration exception" return objectWith this code:
async def aiter(msg): for char in msg: yield charYou can't use
yield from
in async function, but you can use yield to use async generator
, which could be used with async for
.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!