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

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

[Python-Dev] Termination of two-arg iter() [Python-Dev] Termination of two-arg iter()Barry A. Warsaw barry@zope.com
Sun, 14 Jul 2002 22:41:16 -0400
The problem that Jeff Epler brought up (extending the list after
StopIterator was returned, and having a subsequent .next() not give
StopIterator) has a precedence in dict iterators:

-------------------- snip snip --------------------
>>> d = {1:2, 3:4}
>>> it = iter(d)
>>> for x in d: print x
... 
1
3
>>> d[5] = 6
>>> it.next()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
RuntimeError: dictionary changed size during iteration
-------------------- snip snip --------------------

So why doesn't that last .next() also return StopIterator? <wink>.
StopIterator is a sink state for dict iterators if I don't change the
size of the dict.  Shouldn't list and dict iterators should behave
similarly for mutation (or at least resizing) between .next() calls?

-Barry




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