pythondictionarypersistenceobject-persistence

With Python, can I keep a persistent dictionary and modify it?


So, I want to store a dictionary in a persistent file. Is there a way to use regular dictionary methods to add, print, or delete entries from the dictionary in that file?

It seems that I would be able to use cPickle to store the dictionary and load it, but I'm not sure where to take it from there.


Solution

  • If your keys (not necessarily the values) are strings, the shelve standard library module does what you want pretty seamlessly.