Cannot import a module from a variable
Christian Joergensen
mail at razor.dk
Sun Oct 15 11:36:50 EDT 2006
"Jia Lu" <Roka100 at gmail.com> writes:
> Hi all:
>
> I try to do things below:
>>>>import sys
>>>> for i in sys.modules.keys():
> import i
> Traceback (most recent call last):
> File "<pyshell#67>", line 2, in <module>
> import i
> ImportError: No module named i
>
> But it seems that import donot know what is i ? why?
Try using __import__(i) instead.
--
Christian Joergensen | Linux, programming or web consultancy
http://www.razor.dk | Visit us at: http://www.gmta.info
More information about the Python-list
mailing list