within a class, redefining self with pickled file
Greg Ewing
greg at cosc.canterbury.ac.nz
Fri Apr 8 01:47:38 EDT 2005
Sean Blakey wrote:
> On 7 Apr 2005 15:27:06 -0700, syd <syd.diamond at gmail.com> wrote:
>
>> def unpickle(self):
>> self = pickle.load(open(self.getFilePath('pickle')))
> Note, however, that you can MODIFY self in-place within a method. You
> can probably hack together a solution that modifies self.__dict__,
> self.__class__, self.__class__.__dict__, or some other magic
> properties.
such as
def unpickle(self):
new_self = pickle.load(open(self.getFilePath('pickle')))
self.__class__ = new_self.__class__
self.__dict__.update(new_self.__dict__)
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list