Reputation: 12687
In the Python console (Eclipse, Pydev) I execute some data loading. Afterwards I change some source code of a method of the object and would like to include the new functionality in the data objects. The data loading is quite slow so I do not want to restart the whole script.
Is there a magic way to update the object methods with the new implementation that I edited in the source code?
How to reload the code of a method of class object in Python? says I cannot do this in a standard way.
So can you think of some way to simulate that functionality? Maybe reload the class definition and then recreate all data objects by examining their __dict__
or similar? Ideally this would be as automatic and comfortable as possible. What do I need to take into account?
Upvotes: 0
Views: 405
Reputation: 951
Unfortunately, Python can't replace existing instances of objects out of the box. However, IPython
implements this functionality as extension. You could use IPython as Python console or just re-implement this feature for your development environment.
See Autoreload of modules in IPython, and ipython docs.
Upvotes: 1