Hi, I have some problems when pickling an instance of a class, i don't retrieve all its attributes instances after loading. I'm quite a beginner in Python, so it may be a stupid error... Here the full description :
I have a class Test, having an attribute self.problem, as an instance of Problem class, defined in the same module. Problem as an attribute self.optimum, that is a list of Point instances, also defined in the same module. So i use to write self.problem.optimum[i] to get some Points of my Test... I pickle a Test with the following lines : import copy cPickle.dump( copy.deepcopy(self), open('TEST', 'w')) and unpickle in another module with : fd = open( os.path.join(p, 'TEST'), 'r' ) s = cPickle.load( fd ) But the problem is, when i try to access the self.problem.optimum field, i get an empty list, instead of having a list full of Points. I can access string, int, or even Point attributes of Problem. This only happens when i load AFTER restarting Python interpreter. I thought that pickling self from my Test wasn't enought to get instances of attributes copied to, that's why i used a deepcopy(self) instead, but it didn't resolve my problem... I tryed to define a __getState__() method, but didn't help... Can someone help ? Thx -- http://mail.python.org/mailman/listinfo/python-list