__anext__ — Easy Examples
Returns the next value from an async iterator
Implementing __anext__
Basic implementation of __anext__ in a class.
python
class Example: def __anext__(self): return "Example __anext__" obj = Example() print(obj)
__anext__ returns the next value from an async iterator. Implementing it lets you customize how Python interacts with your objects.
__anext__ in action
Seeing __anext__ called by Python's built-in operations.
python
# How Python calls __anext__ automatically class Demo: def __init__(self, value): self.value = value def __anext__(self): print(f"__anext__ was called!") return self d = Demo(42) # This triggers __anext__: print(d)
Python automatically calls __anext__ when you use the corresponding operator or function on your object.
Want to try these examples interactively?
Open Easy Playground