Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

I think this note can be removed.  The tutorial now has coverage of mutating 
while iterating.  That is the correct place for discussion of looping 
techniques.

The part about the "internal counter" needs to be rewritten and moved to 
stdtypes.rst section on Sequence types.  Here is a first draft:

"Forward and reversed iterators over sequences access values using an index.  
That index will continue to march forward (or backward) even if the underlying 
sequence is mutated.  The iterator terminates only when an IndexError or 
StopIteration is encountered (or when the index drops below zero)."

Sequence iterators are roughly equivalent to:

    def seqiter(seq):
        i = 0
        while True:
            try:
                yield seq[i]
            except (IndexError, StopIteration):
                break
            i += 1

----------
assignee: docs@python -> rhettinger
nosy: +rhettinger

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

Reply via email to