[issue17887] docs: summary page - generator vs iterator vs iterable

New submission from anatoly techtonik:
Docs lack a good summary page comparing three concepts. The main question is how do I tell if something is a sequence, generator, iterator or iterable? I found myself puzzled that range() is neither generator or iterator.
---------- assignee: docs@python components: Documentation messages: 188203 nosy: docs@python, techtonik priority: normal severity: normal status: open title: docs: summary page - generator vs iterator vs iterable
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue17887 _______________________________________

Terry J. Reedy added the comment:
Briefly, An iterable is an object that can be iterated with an iterator. An iterator is an iterable that responds to next() calls, including the implicit calls in a for statement. A generator is an iterator created by a generator function, which is a function with a yield keyword in its body. A sequence is an iterable with minimal sequence methods.
The four terms are all in the glossary. The entry for iterable already points to the other three. What do you think is missing?
A range (as documented) is an immutable sequence.
---------- nosy: +terry.reedy
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue17887 _______________________________________

Terry J. Reedy added the comment:
To make the subset relationships clear in the iterable entry, perhaps replace See also iterator, sequence, and generator. with Some iterables are iterators and some iterators are generators. Some iterables are sequences. For details, see iterator, sequence, and generator.
I see that 'generator' is currently used in the 3.3.1 glossary for 'generator function' and there is no entry for generator (object) proper. I thought that had been fixed after pydev discussion.
----------
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue17887 _______________________________________

Changes by Ezio Melotti ezio.melotti@gmail.com:
---------- nosy: +ezio.melotti type: -> enhancement versions: +Python 2.7, Python 3.3, Python 3.4
_______________________________________ Python tracker report@bugs.python.org http://bugs.python.org/issue17887 _______________________________________

Change by Irit Katriel iritkatriel@yahoo.com:
---------- versions: +Python 3.10, Python 3.8, Python 3.9 -Python 2.7, Python 3.3, Python 3.4
_______________________________________ Python tracker report@bugs.python.org https://bugs.python.org/issue17887 _______________________________________
participants (4)
-
anatoly techtonik
-
Ezio Melotti
-
Irit Katriel
-
Terry J. Reedy