Christian Joergensen wrote: > "Jia Lu" <[EMAIL PROTECTED]> 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. > (a) you need something like exec('import ' + i) for most cases but (b) "encodings" is a package i.e. it points to a directory which has an __init__.py file.
Colin W. -- http://mail.python.org/mailman/listinfo/python-list