[issue19414] OrderedDict.values() behavior for modified instance

Ethan Furman report at bugs.python.org
Wed Oct 30 18:15:30 CET 2013


Ethan Furman added the comment:

The further from dict it goes, the more there is to remember.  Considering the work around is so simple, I just don't think it's worth it:

    for key in list(ordered_dict):
        if some_condition:
            del ordered_dict[key]

A simple list around the dict and we're good to go; and this trick works with dicts, defaultdicts, sets, lists (when you don't want the skipping behavior), etc.

----------

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


More information about the Python-bugs-list mailing list