how to import from variable source
Steve Purcell
stephen_purcell at yahoo.com
Sun Apr 15 04:11:55 EDT 2001
Rob Brown-Bayliss wrote:
> module = 'mymod'
> import module
>
> Only, as I found out I get an error stating that there is not module
> called module.
>
> Is this possible in python? Is there a better way perhapse?
Use the __import__() builtin function:
module = __import__('mymod')
-Steve
--
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Any opinions expressed herein are my own and not necessarily those of Yahoo
More information about the Python-list
mailing list