Tim Peters <t...@python.org> added the comment:

Some other points to consider:  I don't think this belongs in the `for` 
statement docs at all.  Instead they should merely _note_ that what happens if 
a sequence being iterated over is mutated is up to the sequence iterator.

Then, e.g., the `list` docs should spell out the behavior currently (but, as 
already noted, incompletely) described.  From StackOverflow experience, I may 
be the only person in the world who knows that list behavior here is documented 
under the `for` statement - everyone else gives up after not finding a word 
about it in the `list` docs ;-)

`collections.deque` docs, in contrast, may wish to document the behavior of its 
iterators.  They in fact work hard to raise an exception if a size-changing 
mutation occurs during iteration, but that doesn't appear to be documented.  
It's worth debating whether it should be.

Are there other mutable sequence types in the standard distribution?

----------
nosy: +rhettinger

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

Reply via email to