[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

2 Bugs: in Python 3 tutorial, and in bugs.python.org tracker registration system

Brian Oney via Python-list wrote:

> That's one thing that confused me. Generators are supposed to be one-off
> iterators. Iterators, *I understood* as reusable iterables.

The way I think about it, informally: iterables need and __iter__ method, 
iterators need a __next__ method.

In practice all iterators are also iterables, and the convention is to have 
__iter__ return self, which makes them one-off. 

Generators are just iterators created in an elegant way, by a function 
containing yield-s.