Reloading function obtained via 'from xxx import yyy'
"Martin v. Löwis"
martin at v.loewis.de
Fri May 23 16:00:30 EDT 2008
> ...and I'd like to reload testFunc. How do I do so? 'from test import
> testFunc' keeps the old definition around, and 'reload test' of course doesn't
> work becayse I didn't use 'import test' in the first place.
Try all three of them, in sequence:
import test
reload(test)
from test import testFunc
del test
If you absolutely don't want to import test, write
reload(sys.modules['test'])
from test import testFunc
OTOH, if you reload often, consider not using from-import at all.
Regards,
Martin
More information about the Python-list
mailing list