aioplus.amax¶
- async aioplus.amax(aiterable, /, *, key=None, default=<enum 'Sentinel'>)¶
Return the largest item in
aiterable.- Parameters:
aiterable (AsyncIterable[T]) – An asynchronous iterable of objects.
key (Callable[[T], SupportsRichComparison], optional) – A function that extracts a comparison key from each element in the iterable.
default (D, optional) – A default value to return if the iterable is empty.
- Returns:
The largest item in the iterable or the default value.
- Return type:
T or D
Examples
>>> import asyncio >>> >>> from aioplus import amax, arange >>> >>> async def main() -> None: >>> '''Run the program.''' >>> aiterable = arange(23) >>> largest = await amax(aiterable) >>> print(f'max(aiterable) == {largest}') >>> >>> if __name__ == '__main__': >>> asyncio.run(main())
See also