[docs] [issue16225] add to "looping techniques" tutorial a note about modifying sequence

Raymond Hettinger report at bugs.python.org
Tue Oct 16 03:24:42 CEST 2012


Raymond Hettinger added the comment:

> > It will be nice somewhere in deep clarify 
> > for experts what happens with list iterator if the list changed.

Resist the urge to over-specify.  Unless the behavior is tested and known to be consistent across all implementations, I'm content with the current docs:

"Note There is a subtlety when the sequence is being modified by the loop...."

Chris's currently patch seems reasonable to me and I don't think anything further is a good idea.

With nearly any data structure in any language, most programmers learn to be cautious about and generally avoid looping over a structure while mutating it.  Adding yet more documentation details won't make the issue go away.

I recommend posting the current patch and closing this issue to be done with it.

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

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16225>
_______________________________________


More information about the docs mailing list