[Tutor] Reading module to import from a string
Mark Tolonen
metolone+gmane at gmail.com
Tue Dec 16 16:39:57 CET 2008
"Shrutarshi Basu" <technorapture at gmail.com> wrote in message
news:376fbdcf0812151438w53c8f3f7rc1dc481b524282bc at mail.gmail.com...
> Suppose I have a module that I want to import called ImMod1 that's
> saved in a variable like so:
>
> var = "ImMod1"
>
> Is there some way to import ImMod1 by using var?
> Thanks,
> Basu
mod = __import__(var)
-Mark
More information about the Tutor
mailing list