aioplus.aany

async aioplus.aany(aiterable, /)

Return True if any element of the async iterable evaluates to True.

Parameters:

aiterable (AsyncIterable of SupportsBool) – An asynchronous iterable of objects supporting object.__bool__().

Returns:

True if any element evaluates to True. False if all elements evaluate to False, or if the iterable is empty.

Return type:

bool

Examples

>>> import asyncio
>>>
>>> from aioplus import aany, arange
>>>
>>> async def main() -> None:
>>>     '''Run the program.'''
>>>     aiterable = (num % 2 == 0 async for num in arange(2304))
>>>     flg = await aany(aiterable)
>>>
>>> if __name__ == '__main__':
>>>     asyncio.run(main())

Notes

  • Short-circuits on the first object that evaluates to True.

See also

any()