aioplus.anth

async aioplus.anth(aiterable, /, *, n, default=<object object>)

Return the nth item or a default value.

Parameters:
  • aiterable (AsyncIterable[T]) – An asynchronous iterable to retrieve the nth item from.

  • n (SupportsIndex) – The index of the item to retrieve, starting from 0.

  • default (D, optional) – A default value to return if the nth item does not exist. If not provided, IndexError will be raised if the nth item is not found.

Returns:

The nth item or the default value.

Return type:

T or D

Examples

>>> aiterable = arange(23)
>>> await anth(aiterable, n=4)
4