So it happens often that i while i’m in ipython, i want to edit the display methods and test them without reloading the data. I tried pickling the data but pickle complained about it for some reason, so my only option was to edit the methods in place and while ipython is great, i prefer my editor, besides i want to store the code in case it, you know, works. So i type reload Module then foo.__class__ = Module.Foo and voila! all the methods change but the instance variables remain the same so i don’t have to reload the data!!Source.
2008/12/08
Python: changing the class of an instance
Subscribe to:
Posts (Atom)