How do you make a class iterable?
Iterators and iterables
Audio flashcard · 0:14Nortren·
How do you make a class iterable?
0:14
Implement dunder iter on the class. The method should return an iterator, which can be the object itself if it also implements dunder next, or a separate iterator object. For most cases, returning a generator from dunder iter is the cleanest approach.
docs.python.org