Naivelly I would use:
for k, v in dictionary.items():
if foo(v):
del dictionary[k]
However this will cause an iterator exception as I edit the dictionary size while iterating over it. So how could I do this? - and especially, without making a copy of the dictionary, the copy approach:
copydict = dict(dictionary)
for k, v in copydict.items():
if foo(v):
del dictionary[k]
I wish to see how python would do such in place editing without actually using explicit iterators.