Posted by Dave on



Some notes on Python Pickle. See below/overleaf.

It reminds me of tape files, seems to be only open in read or write mode.

dictfile = open('bookmarks.pickle','rb')
D = {};                     # the input dictionary
D = pickle.load(dictfile) ; # loads a dictionary
dictfile.close();           # so the db can be opened for writing

This code works, you seem to need to close it before it permits you to open the pickle file in write mode.

del D[duff]

dictfile = open('bookmarks.pickle','wb')

In all the cases above, there is room for substitution, but this works.

I use the statement import pickle.


Comment ( 1 )

  1. delicious linkrolls |
    […] links are held in a pickle database, which could easily be converted to XML or JSON. I have code to delete a record on the […]

This site uses Akismet to reduce spam. Learn how your comment data is processed.