aioplus.arepeat

aioplus.arepeat(obj, /, *, times=None)

Yield the same object repeatedly, either infinitely or a fixed number of times.

Parameters:
  • obj (T) – The object to yield repeatedly.

  • times (int, optional) – Number of repetitions. Must be an object supporting object.__index__(). If None, the object is yielded indefinitely.

Returns:

An asynchronous iterable yielding the same object multiple times.

Return type:

AsyncIterable of T

Examples

>>> import asyncio
>>>
>>> from aioplus import arepeat
>>>
>>> async def main() -> None:
>>>     '''Run the program.'''
>>>     async for num in arepeat(23, times=4):
>>>         print(num)
>>>
>>> if __name__ == '__main__':
>>>     asyncio.run(main())