sri2097 wrote: > Hi all, I'm storing number of dictionary values into a file using the > 'cPickle' module and then am retrieving it. The following is the code > for it - > > # Code for storing the values in the file > import cPickle > > book = {raw_input("Name: "): [int(raw_input("Phone: ")), > raw_input("Address: ")] } > file_object = file(database, 'w+') > cPickle.dump(book, file_object) > file_object.close() >
I may be misunderstanding you - but it seems you just want to read a pickle, modify it, and then write it back ? What you're doing is appending the modified pickle to the original one - which is more complicated than what you want to achieve. file_object = open(filename, 'rb') stored_dict = cPickle.load(file_object) file_object.close() ... code that modifies stored_dict file_object = open(filename, 'wb') cPickle.dump(stored_dict, file_object) file_object.close() Any reason why that shouldn't do what you want ? All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list