Deleting dictionary items

Andreas Jung andreas at andreas-jung.com
Sat Mar 17 09:23:18 EST 2001


"Will Newton" <will at nospam.misconception.org.uk> schrieb im Newsbeitrag
news:98ug6n$q9d$1 at news6.svr.pol.co.uk...


>                 for item in td.data.keys():

#                What td.data ?  I assume td.data is your dictionary ?
#                 item is now a tuple (x1,x2,x3...)

>                         if item[attr] != value:

#                  you can access the tuples elements by their position
using the [] operator
#                  e.g. item[0] gives x1, item[1] gives x2 ...
#
>                                 del td.data[item]

#                  This should work

Andreas







More information about the Python-list mailing list