Nicier code for this?

Remco Gerlich scarblac at pino.selwerd.nl
Mon May 21 08:17:08 EDT 2001


Roman Suzi <rnd at onego.ru> wrote in comp.lang.python:
> I know exec is not very nice, but I am not sure if something
> better exists for the following:
> 
> fake, v = {}, {}
> exec """from mod_%s import func""" % modname in fake, v
> return v["func"](args)

module = __import__("mod_"+modname)
return getattr(module, "func")(args)

-- 
Remco Gerlich



More information about the Python-list mailing list