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/026505.html below:

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

[Python-Dev] Termination of two-arg iter()Greg Ewing greg@cosc.canterbury.ac.nz
Mon, 15 Jul 2002 13:51:56 +1200 (NZST)
> What about this example?
> >>> l = []
> >>> li = iter(l)
> >>> li.next()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> StopIteration
> >>> l.extend([1, 2, 3])
> >>> li.next()
> 1
> 
> does the list iterator violate the proposed behavior?

Perhaps the docs should say something like "The next()
method raises StopIteration if there are no more items
remaining in the sequence at the time of the call."

This would both imply the repeated raising of
StopIteration in the case where the sequence hasn't
been modified in the meantime, and also allow the
above behaviour (which seems entirely logical, to
my way of thinking).

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+




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