On this page
anext
Prev: all | Up: __builtins__ | Next: any
Rel: all, any, enumerate, filter, iter
Ref: docs.python.org — anext
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import anext
Overview & Signature
anext(...)
Return the next item from the async iterator.
Usage
import asyncio
async def gen():
yield 10
async def main():
it = aiter(gen())
assert await anext(it) == 10
assert await anext(it, None) is None
asyncio.run(main())
Gotchas
- Requires Python 3.10+: Pass a second
defaultargument to avoid catchingStopAsyncIteration.
REPL Inspect
help(anext)
Linked from
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/all Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/any Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/python3/__builtins__/enumerate Linked here; shared tags: #builtins
- tuts/python3/__builtins__/filter Linked here; shared tags: #builtins
- tuts/python3/__builtins__/iter Linked here; shared tags: #builtins
- tuts/c/builtins shared tags: #builtins
- tuts/c/builtins/__FILE__ shared tags: #builtins
- tuts/c/builtins/__func__ shared tags: #builtins