Loop through a dict changing keys
Ian Kelly
ian.g.kelly at gmail.com
Mon Oct 17 14:12:27 EDT 2011
On Mon, Oct 17, 2011 at 10:21 AM, 88888 dihedral
<dihedral88888 at googlemail.com> wrote:
> Uh, sounds reasonable, if one loops over an index variable that could be altered during the loop execution then the loop may not end as expected.
>From the docs: "Iterating views while adding or deleting entries in
the dictionary may raise a RuntimeError or fail to iterate over all
entries."
Changing the values of existing entries while iterating is considered
to be safe, though.
More information about the Python-list
mailing list