Newbie question.. how to load modules with a dynamic name?

Ron Scinta nb0klun71q5001 at sneakemail.com
Fri Feb 23 14:47:47 EST 2001


I have a need to run various python script files from a master control
 script, however, I do not know the names of the scripts until runtime.

 I will be getting the script names from a database.. and was thinking I
 could just use the import call with the supplied name.

 This does not work alas....
 >>> mymod = "ptw"
 >>> import mymod
 Traceback (innermost last):
   File "<interactive input>", line 1, in ?
 ImportError: No module named mym
 >>>

 What is the prefered method of doing this type of operation?

 Any help would be greatly appreciated!

 Best Regards,
 Ron










More information about the Python-list mailing list