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.

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to