New submission from Trey Hunner <trey@truthful.technology>:

>From the itertools documentation: 
>https://docs.python.org/3/library/itertools.html?highlight=itertools#itertools.count

> Also, used with zip() to add sequence numbers.

I'm not certain what the goal of the original sentence was, but I think it's 
unclear as currently written.

I assume this is what's meant:

my_sequence = [1, 2, 3, 4]
for i, item in zip(count(1), my_sequence):
    print(i, item)

This is a strange thing to note though because enumerate would be a better use 
here.

my_sequence = [1, 2, 3, 4]
for i, item in enumerate(my_sequence, start=1):
    print(i, item)

Maybe what is meant is that count can be used with a step while enumerate 
cannot?

my_sequence = [1, 2, 3, 4]
for i, item in zip(count(step=5), my_sequence):
    print(i, item)

If that's the case it seems like step should instead be mentioned there instead 
of "sequence numbers".

----------
assignee: docs@python
components: Documentation
messages: 313606
nosy: docs@python, trey
priority: normal
severity: normal
status: open
title: itertools.count() confusingly mentions zip() and sequence numbers
type: enhancement
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33049>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to