Reloading modules

Quinn Dunkan quinn at riyal.ugcs.caltech.edu
Sun Jun 25 15:26:09 EDT 2000


On Sun, 25 Jun 2000 17:09:36 +0100, Duncan Smith
<buzzard at urubu.freeserve.co.uk> wrote:
>>>> from Graph import *
>.
>.
>.
>>>> reload(Graph)
>Traceback (innermost last):
>  File "<interactive input>", line 1, in ?
>TypeError: reload() argument must be module
>
>What do I need to do to successfully reload a module?  I'm currently wasting
>a lot of time re-starting PythonWin each time I want to test a changed
>module and I can't find the answer.  Thanks

'from x import ...' doesn't actually bring the module into the
namespace, just its contents.  You can get mostly what you want
with 

del sys.modules['Graph']
from Graph import *'

If it's just interactive testing, then feel free to use nasty tricks like
that.  But for real code, you should generally stay away from them.



More information about the Python-list mailing list