how to import from variable source
Alex Martelli
aleaxit at yahoo.com
Sun Apr 15 12:43:59 EDT 2001
"Martin Bless" <m.bless at gmx.de> wrote in message
news:3ad998f3.3543207 at news.muenster.de...
> >Use the __import__() builtin function:
> >
> > module = __import__('mymod')
>
> Is there a way to manipulate the resulting 'mymod.__name__'?
Not with __import__, I think.
> If - against normal behavior - it could be set to '__main__' the
> imported 'mymod' could be deceived leading to execution of code
You can do that with the imp.load_module() function.
Alex
More information about the Python-list
mailing list