Loading a module by expanding a string variable?

Matthew Dixon Cowles matt at mondoinfo.com
Thu Oct 26 17:16:56 EDT 2000


On 26 Oct 2000 23:07:24 +0200, Joakim Hove <hove at phys.ntnu.no> wrote:

>I have written two modules Mod1 and Mod2, and then I want load either
>Mod1 or Mod2 - depending on the value of a string variable. 

Joakim,
One way to do what you want is to read the appropriate module into a
string and then use Fredrik Lund's technique for importing a module
from a string. It's at:

http://www.deja.com/getdoc.xp?AN=621152936

Regards,
Matt



More information about the Python-list mailing list