reloading my own modules
Skip Montanaro
skip at pobox.com
Tue Jun 7 10:37:47 EDT 2005
Lowell> import dbtest, util
Lowell> for module in ['dbtest', 'util']:
Lowell> if module in sys.modules.keys():
Lowell> reload(sys.modules[module])
Lowell> Is this the best way to do it? It seems a bit verbose, but not
Lowell> really all that bad. I was just wondering if there is a more
Lowell> standard way to do it?
Not that I'm aware of. You don't need to request the keys() of a dict in
recent versions of Python:
import dbtest, util
for module in ['dbtest', 'util']:
if module in sys.modules:
reload(sys.modules[module])
Also, since it's clear you have already imported dbtest and util, there's no
need to check in sys.modules:
import dbtest, util
reload(dbtest)
reload(util)
Skip
More information about the Python-list
mailing list