What is the best way to do dynamic imports ?
marcroy.olsen at gmail.com
marcroy.olsen at gmail.com
Sun Dec 30 09:24:53 EST 2007
Hi list and python gurus :-)
I'm playing with some mod_python and web development. And in me code I
need to do som dynamic imports.
Right now I just do a:
exec 'import '+some_modulename
But it seems to easy, is there a "dark side" to doing it this way?
(memory use,processing ,etc)
And have to I check if the modul is already loaded?
Another thing is how to call my dynamic imported moduls.
Now I use exec (as with my modules), like this:
exec 'newclass = '+classname+'()'
newclass.somefunction()
Again it seems to easy. Is there a better/proper way to do it?
Do anybody now a good howto or tutorial to this?
Many thanks and hope you all have a happy new year :-)
/marc
More information about the Python-list
mailing list