A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-July/026474.html below:

[Python-Dev] Termination of two-arg iter()

[Python-Dev] Termination of two-arg iter() [Python-Dev] Termination of two-arg iter()Andrew P. Lentvorski bsder@mail.allcaps.org
Sun, 14 Jul 2002 03:23:25 -0700 (PDT)
On Sun, 14 Jul 2002, Brett Cannon wrote:

> end.  It seems like StopIteration is saying "stop please" and
> IteratorExhausted would be like screaming "STOP CALLING .next()!!!".

What about raising IndexError by default when someone attempts to call
.next() on an iterator already raising StopIteration?

In the case of a list, StopIteration signals that the iterator is pointing
to just beyond the end of the list.  An attempt to call .next() when
StopIteration is already true is effectively an attempt to dereference
past the end of a list (since .next() normally wants to return a value).

List accesses via an index past list end currently raise an IndexError.
Doing something similar for iterators would seem to keep things
consistent.

-a







RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4