A beginner's problem...

Nick Coghlan ncoghlan at iinet.net.au
Sat Dec 18 23:49:03 CET 2004

Amir Dekel wrote:
> Mike Meyer wrote:
>> Doing a second import will find the module in sys.modules and not
>> bother looking in the file system. The solution is to reload(module)
>> instead of import module.
>>         <mike
> What if I import using "from module import class"? It seems to me that I 
> can't use reload then, or I just couldn't find the right syntax...

Correct. Using a non-from import is actually easier when experimenting, since 
reload is easier to use.

If you have used a from-style import, you have to do this to force a reload of 
the relevant class:

Py> from module import x
Py> # Do stuff
Py> import module
Py> reload(module)
Py> from module import x
Py> # We now have the updated version of x


Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia

More information about the Python-list mailing list