When you use for item in o for some iterable object o, Python calls iter(o) and expects an iterator object as the return value. An iterator is any object which implements a next (or next in Python 2) method and an iter method. By convention, the iter method of an iterator should return the object itself (i.e. return self).