Iterators are defined in the Python documentation as objects implementing both
__next__(), so objects of the
Iterator class in your example are not, properly speaking, iterator objects. You should add
def __iter__(self): return self
Iterator class definition: surprising and unexpected bugs can come out of using
Iterator objects as iterator objects (haha) while failing to fully implement the iterator protocol — as you demonstrated with the
for e in myiterator example.