What is the most basic definition of \"iterable\", \"iterator\" and \"iteration\" in Python?
I have read multiple definitions but I am unable to identify the exact m
Iterables have a __iter__ method that instantiates a new iterator every time. Iterators implement a __next__ method that returns individual items, and a __iter__ method that returns self . Therefore, iterators are also iterable, but iterables are not iterators.
Iterables have a __iter__ method that instantiates a new iterator every time.
__iter__
Iterators implement a __next__ method that returns individual items, and a __iter__ method that returns self .
__next__
self
Therefore, iterators are also iterable, but iterables are not iterators.
Luciano Ramalho, Fluent Python.