Last active
December 20, 2015 04:29
-
-
Save andrewgiessel/6071508 to your computer and use it in GitHub Desktop.
save and load wrappers for pickle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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