In general, what does an object need to have in order to be an iterator? Programmatically, what does class need to have in Python to be used as an iterator?
1 Answer
You need to implement __iter__(), which should return an iterator object. The iterator object should implement next(), which will raise a StopIteration exception on iteration completion.
http://docs.python.org/2/library/stdtypes.html#iterator-types