Skip to content

Instantly share code, notes, and snippets.

@davidbj
Created February 17, 2014 03:37
Show Gist options
  • Select an option

  • Save davidbj/9044298 to your computer and use it in GitHub Desktop.

Select an option

Save davidbj/9044298 to your computer and use it in GitHub Desktop.
I.pickle exmaple
"""object save to file."""
import pickle
obj = Someobject()
f = open(filename, 'wb')
pickle.dump(obj, f)
f.close()
"""load file value"""
import pickle
f = open(filename, 'rb')
obj = pickle.load(f)
f.close()
II.shelve example
import shelve
obj = SomeObject()
db = shelve.open("filename")
db['key'] = obj
obj = db['key'] #index object value
db.close() #close shelve and save to filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment