This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Itertools documentation says iterator when iterable is intended
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: NeilGirdhar, docs@python, steven.daprano
Priority: normal Keywords:

Created on 2015-07-13 01:37 by NeilGirdhar, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg246676 - (view) Author: Neil Girdhar (NeilGirdhar) * Date: 2015-07-13 01:37
In the description of the consume recipe:

def consume(iterator, n):
    "Advance the iterator n-steps ahead. If n is none, consume entirely."
    # Use functions that consume iterators at C speed.
    if n is None:
        # feed the entire iterator into a zero-length deque
        collections.deque(iterator, maxlen=0)
    else:
        # advance to the empty slice starting at position n
        next(islice(iterator, n, n), None)

iterator should be replaced with iterable.  This function accepts strings for example, which are not iterators.
msg246678 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2015-07-13 01:57
On Mon, Jul 13, 2015 at 01:37:26AM +0000, Neil Girdhar wrote:
> 
> New submission from Neil Girdhar:
> 
> In the description of the consume recipe:
[...]
> iterator should be replaced with iterable.  This function accepts strings for example, which are not iterators.

It *accepts* strings, but it doesn't consume them. It runs through the 
string, but the string still exists and you can iterate over it again 
and again and again.

The intent of the recipe is to consume an *iterator* not arbitrary 
iterables. I don't believe the recipe or its description needs to be 
changed.
msg246683 - (view) Author: Neil Girdhar (NeilGirdhar) * Date: 2015-07-13 06:20
Ah, good point.
History
Date User Action Args
2022-04-11 14:58:18adminsetgithub: 68812
2015-07-13 06:20:01NeilGirdharsetmessages: + msg246683
2015-07-13 03:28:05r.david.murraysetstatus: open -> closed
resolution: not a bug
stage: resolved
2015-07-13 01:57:42steven.dapranosetnosy: + steven.daprano
messages: + msg246678
2015-07-13 01:37:26NeilGirdharcreate