Hello all, I'm using the Shelve module to store dictionaries in a list as a value of a key.

So:

key = [{'keyA' : 1, 'keyB' : 2}, {'key1' : 1, 'key2' : 2}]

The problem is I can't remove a dictionary from the list.


import shelve

s = shelve.open('file')
try:
   for index, value in enumerate(s['key']):
       if value['keyA'] == 1 and value['keyB'] == 2:
           del value[index]
finally:
   s.close()


If I do some printing in between, I can see the dictionary actually gets removed, but doesn't get saved. Any ideas why?
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to