Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

I concur with Josh.  This matches the documented behavior and isn't a bug. 
Marking as closed.

There are potentially two ways to stop sequence iteration, either by using len 
or by waiting for IndexError.  Python uses the latter to allow lists to be 
dynamically resized during iteration and because checking len on every 
iteration would be expensive.  

If someone doesn't read the docs, and assumes Python uses len, and writes an 
inconsistent class (one where len doesn't match the point where IndexError is 
raised), then there is little we can do to prevent that person from being 
"surprised".

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34494>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to