"Carter Danforth" <carter.danfo...@gmail.com> wrote
Hi, I'm trying to a create a basic addressbook for practice. I'm
using a
dictionary with cpickle, though I'm not sure how to persistently
store each
instance in the dictionary. Below is the code I have so far.
If you use a dictionary it makes more sense to use shelve rather than
pickle for storage.
Shelve uses pickle under the hood but it makes a file look like a
dictionary so you
don't need to load all the data and store it all again as you would
with pickle.
Unfioortunately your code appears to be truncated, however...
import cPickle as p
addressbook = 'addressbook.data'
f = file(addressbook, 'r+')
I think you should use a binary file for pickle so the mode should be
'rb' not 'r+'
HTH,
Alan G
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor