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.

Author rhettinger
Recipients docs@python, eric.araujo, rhettinger, turepalsson
Date 2021-12-18.02:13:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1639793604.67.0.898324248225.issue46095@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-12-18 02:13:24rhettingersetrecipients: + rhettinger, eric.araujo, docs@python, turepalsson
2021-12-18 02:13:24rhettingersetmessageid: <1639793604.67.0.898324248225.issue46095@roundup.psfhosted.org>
2021-12-18 02:13:24rhettingerlinkissue46095 messages
2021-12-18 02:13:24rhettingercreate