How to import a module based on an argument

Michel Claveau/Hamster No.Spam.mc at No.Spam.mclaveau.No.Spam.com
Thu Mar 25 22:03:33 CET 2004


Hi !

No nice, but :

    def functionname( module, var1):
            exec("import "+module)
            print string.upper(var1)

    functionname('string', 'azerty')








More information about the Python-list mailing list