On Apr 4, 2005 5:29 PM, Tim Roberts <[EMAIL PROTECTED]> wrote: > If I needed to refer to an 89MB disk file in an > object, I would replace the data with the file name before pickling. I > thought pickle recognized a magic method name so the object could "help" > put itself into a picklable state, but I don't see it now.
You're probably thinking of __setstate__ and __getstate__. Something like this (untested) should work: def __getstate__(self): state = {} for key in self.__dict__: # don't pickle "data" if key != 'data': state[key] = self.__dict__[key] def __setstate__(self, state): self.__dict__.update(state) # get "data" back from the filesystem self.data = open(self.file).read() There is also a __reduce__ method, and copy_reg.pickle. Paul. _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32