I am launching an interactive python session that creates large python data structures (5+ GB) that take a lot of time to load, and therefore I want to use Python on-the-the ( ), maximum (although sometimes without having to plan too much for of this ).
My current problem is this: I have an old instance of the class, which I later modified the code and reloaded the module. I would like the old instance to be able to use the new function definitions. How can I do this without manually copying all the information from the old instance to the new fresh instance?
Here is what I have tried. Suppose I have an M.py module:
class A(): def f(self): print "old class"
Here is an interactive session:
import M old_a = Ma()
at this moment I get the following type error from Python:
TypeError: unbound method f() must be called with A instance as first argument (got A instance instead)
Python is obviously not happy to get the old instance of A, although they are basically functionally equivalent (in my code) - is there a way that I could βtypeβ it for a new instance type so that Python canβt complain? Something moral: MAf( (MA) old_a ) ?
source share