[issue41892] use both "for in" and "ElementTree.remove" has a index bug

Stefan Behnel report at bugs.python.org
Wed Sep 30 11:09:42 EDT 2020


Stefan Behnel <stefan_ml at behnel.de> added the comment:

> That example is especially problematic.

No, it's not. It uses .findall(), which returns a list. It's like when you make a copy of a list to iterate over, when you want to modify the original list in the loop.

That could be made explicit in the text that introduces the example, but I think it's a very good example.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41892>
_______________________________________


More information about the Python-bugs-list mailing list