A RetroSearch Logo

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

Search Query:

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

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

[Python-Dev] Termination of two-arg iter() [Python-Dev] Termination of two-arg iter()Oren Tirosh oren-py-d@hishome.net
Sun, 14 Jul 2002 07:27:45 -0400
On Sun, Jul 14, 2002 at 03:23:25AM -0700, Andrew P. Lentvorski wrote:
> 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?

+1

IndexError is probably better than inventing a new exception. The description 
of what actually happened would be in the exception text.

StopIteration means "That was the last item, thank you. Sorry I couldn't tell
you my length in advance -- I'm an iterator and I don't even know it myself."

This type of IndexError would mean "Hey, I told you it was the last item. 
This would have been an out-of-bounds index if I were a sequence".

	Oren




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