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

Peter Otten __peter__ at web.de
Sat Sep 22 09:34:47 EDT 2018


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.




More information about the Python-list mailing list