Skip to content

Instantly share code, notes, and snippets.

@andrewgiessel
Last active December 20, 2015 04:29
Show Gist options
  • Save andrewgiessel/6071508 to your computer and use it in GitHub Desktop.
Save andrewgiessel/6071508 to your computer and use it in GitHub Desktop.
save and load wrappers for pickle
import cPickle as pickle
def save(obj, filename):
"""Simple wrapper to pickle an object on disk
:param: obj, any pickable object
:param: filename, string representation of the file to save to
"""
with open(filename, 'wb') as f:
pickle.dump(obj, f)
def load(filename):
"""Simple wrapper load a pickled an object from disk
:param: filename, string representation of the file to load from
:returns: the object saved in the file
"""
with open(filename) as f:
return pickle.load(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment