I\'m trying to pickle an instance of a class in one module, and unpickle it in another.
Here\'s where I pickle:
import cPickle
def pickleObject():
Jeremy Brown had the right answer, here is a more concrete version of the same point:
import cPickle
import myFooDefiningModule
def pickleObject():
object = myFooDefiningModule.Foo()
savefile = open('path/to/file', 'w')
cPickle.dump(object, savefile)
and:
import cPickle
import myFooDefiningModule
savefile = open('path/to/file', 'r')
object = cPickle.load(savefile)
such that Foo
lives in the same namespace in each piece of code.