A: importing dynamic files, reloading .so
Jan Kybic
Jan.Kybic at epfl.ch
Wed Oct 18 04:56:10 EDT 2000
> I was just wondering if there is a way to import a module where the module
> name is dynamic (basically contained in a string). The idea is that the
You can use exec() to execute arbitrary strings. For example:
demomodules=['MosSplnreg', 'MosLandmarks2D' ]
for i in demomodules: exec('import '+i)
> The second part is removing these imports. Is there a way to 'unimport' a
> module? The python website seems to be very lacking on such topics.
As far as I know, 'del' works. For example:
import sys
del sys
If you just want to reload a new version, use reload(), such as reload(sys)
Jan
--
-------------------------------------------------------------------------
Jan Kybic <Jan.Kybic at epfl.ch> BIG IOA DMT EPFL Lausanne, Switzerland
or <kybic at ieee.org> tel. work +41 (21) 693 5142
For PGP key see my WWW page. http://bigwww.epfl.ch/kybic
More information about the Python-list
mailing list