Possible to import a module whose name is contained in a variable?
Gerrit Holl
gerrit at nl.linux.org
Mon Mar 7 08:52:02 EST 2005
Ed Leafe wrote:
> On Mar 7, 2005, at 5:23 AM, Michael Hoffman wrote:
> >Avoiding exec (which is a statement, not a function) is much more
> >important. Since it executes arbitrary code, you can get unpredictable
> >results from it.
>
> Is there any way to use __import__ to replace the following:
>
> exec("from %s import *" % modulename)
No.
Gerrit.
--
Weather in Twenthe, Netherlands 07/03 13:25:
4.0°C Few clouds mostly cloudy wind 5.4 m/s NW (57 m above NAP)
--
In the councils of government, we must guard against the acquisition of
unwarranted influence, whether sought or unsought, by the
military-industrial complex. The potential for the disastrous rise of
misplaced power exists and will persist.
-Dwight David Eisenhower, January 17, 1961
More information about the Python-list
mailing list