[docs] [issue32767] Mutating a list while iterating: clarify the docs
Tim Peters
report at bugs.python.org
Mon Feb 5 21:08:01 EST 2018
Tim Peters <tim at 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 <report at bugs.python.org>
<https://bugs.python.org/issue32767>
_______________________________________
More information about the docs
mailing list