Let's face it, the whole business of reloading python code after changing it is a mess. I figured out awhile back that calling import <module>
at the interpreter is better than from <module> import <class/function>
, because then I can call reload(module)
to get updated code.
But I have more complicated issues now. So I have this file, module1.py, and at the top it says:
from module2 import <class1>, <function1>, etc.
And then I go and change code inside module2. Turns out that calling reload(module1)
will not reload the code changed in module2, even though code from module2 is imported at the top of module1. Is there any way to reload everything without restarting the interpreter?
Before anyone gets on my case about style, I'll just say that:
- I only call
reload
from the interpreter, never in active code. This question concerns when I'm testing new code. - I never call from
<module> import *
, I know that destroys readability