osdir.com


[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


On 22Sep2018 12:08, Brian Oney <brian.j.oney at googlemail.com> wrote:
>That's one thing that confused me. Generators are supposed to be one-off iterators. Iterators, *I understood* as reusable iterables.

You've misread the grammar (the semantics). Iterators are one off - they're 
something that counts (for want of a better word which isn't "iterates") though 
something.

An _iterable_ is something which can be iterated over, and therefore is 
something from which an iterator can be made to do that.

So an iterator is what does the iterating, a single pass over whatever it is.

An iterable is something you can iterate over, using an iterator.

Cheers,
Cameron Simpson <cs at cskk.id.au>