On this page
typing.AsyncIterator
Prev: typing.AsyncIterable | Up: typing | Next: typing.Awaitable
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.AsyncIterator
Tags: #public #python3 #stdlib #typing
Import
import typing
from typing import AsyncIterator
Signature & Overview
typing.AsyncIterator(*args, **kwargs)
Deprecated alias to collections.abc.AsyncIterator.
Usage
from typing import AsyncIterator
async def take_first(it: AsyncIterator[str]) -> str:
return await it.__anext__()
assert callable(take_first)
Gotchas
- Prefer
collections.abc.AsyncIterator[T]in Python 3.9+: Great return type for simple async generators that don't use.asend().
REPL Inspect
from typing import AsyncIterator
help(AsyncIterator)
Linked from
Related notes
- tuts/python3/stdlib_module/typing/AsyncIterable Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Awaitable Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/typing/AbstractSet Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Annotated Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Any Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_never Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_type shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncContextManager shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncGenerator shared tags: #stdlib, #typing