aioplus.ahead¶
- aioplus.ahead(aiterable, /, *, n)¶
Return the first
nitems of theaiterable.- Parameters:
aiterable (AsyncIterable[T]) – An asynchronous iterable to retrieve items from.
n (SupportsIndex) – The number of items to retrieve from the start.
- Returns:
An asynchronous iterable yielding the first
nitems of theaiterable.- Return type:
AsyncIterable[T]
Examples
>>> import asyncio >>> >>> from aioplus import ahead, arange >>> >>> async def main() -> None: >>> '''Run the program.''' >>> async for num in ahead(arange(23), n=4): >>> print(num) >>> >>> if __name__ == '__main__': >>> asyncio.run(main())
See also