[issue41892] use both "for in" and "ElementTree.remove" has a index bug
Stefan Behnel
report at bugs.python.org
Wed Sep 30 11:31:18 EDT 2020
Stefan Behnel <stefan_ml at behnel.de> added the comment:
@WoodyWoo, you can (and should) do something like this:
for ELEMchild in list(etroot):
Modifying a container while iterating over it is usually not a good idea. The same applies to Python lists and dicts, for example.
----------
stage: patch review ->
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41892>
_______________________________________
More information about the Python-bugs-list
mailing list