Deleting dictionary items

Will Newton will at nospam.misconception.org.uk
Fri Mar 16 20:58:15 EST 2001


What's the best way to delete dictionary items?

I have a dictionary with tuples as keys, and I would like to delete all 
keys with a certain element. First I wrote:

                for item in td.data.keys():
                        if item[attr] != value:
                                del td.data[item]


But will this work?



More information about the Python-list mailing list