Automatic reloading, metaclasses, and pickle

andrewfelch at gmail.com andrewfelch at gmail.com
Tue Feb 27 14:41:11 EST 2007


Hello all,

I'm using the metaclass trick for automatic reloading of class member
functions, found at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164

My problem is that if I
1) pickle an object that inherits from "AutoReloader"
2) unpickle the object
3) modify one of the pickled' object's derived class methods
4) reload the module holding the class

... then the changes don't affect the unpickled object.  If I unpickle
the object again, of course the changes take effect.

My friend that loves Smalltalk is laughing at me.  I thought I had the
upperhand when I discovered the metaclasses but now I am not sure what
to do.  I really don't want to have to unpickle again, I'm processing
video and it can take a long time.

By the way, I used to avoid all of these problems by never making
classes, and always building complex structures of lists,
dictionaries, and tuples with global functions.  It's going to take me
a while to kick those horrible habits (during my transition, I'm
deriving from list, dict, etc. hehe), perhaps a link to the metaclass
trick is in order in the tutorial's comments on reload?

Any help that avoids having to unpickle again is appreciated!

Thanks,
Andrew Felch




More information about the Python-list mailing list