This Stack Overflow post is about making an object an iterator in Python.
In Python 2, that means you need to implement an __iter__()
method, and a next()
method. But in Python 3, you need to implement a different method, instead of next()
you need to implement __next__()
.
How does one make an object which is an iterator in both Python 2 and 3?