reloading my own modules

Lowell Kirsh lkirsh at cs.ubc.ca
Mon Jun 6 23:45:28 EDT 2005


I have a driver module as well as several other modules. I am running 
the driver interactively from emacs - that is, I don't restart python on 
each run. I want to work it such that every time a modify the source for 
one of the non-driver modules and re-run the driver, the other modules 
will be reloaded. I have the following at the top of my driver module:

import dbtest, util
for module in ['dbtest', 'util']:
     if module in sys.modules.keys():
         reload(sys.modules[module])

Is this the best way to do it? It seems a bit verbose, but not really 
all that bad. I was just wondering if there is a more standard way to do it?

Lowell



More information about the Python-list mailing list