$ python
>>> import myapp
>>> reload(myapp)
<module 'myapp' from 'myapp.pyc'>
>>>
ctrl+D
$ python
>>> from myapp import *
>>> reload(myapp)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'myapp' is not defined
Why this behaves differently? How can I reload when using from myapp import *?
reloadis to be used with a lot of caution. It behaves unexpected in many ways, the worst of which is that classes exist in many versions inside the VM, depending on whether you have old instances of reloaded classes hanging around.reloadwas removed from Python 3 for that reason. Often it's much easier to set up a small script setting up all the modules you need and then drop into a shell usingimport code; code.interact(local=locals()). The Python interpreter starts up really fast, so this is usually even faster then searching forreloadin the readline history.