NEWBIE TIP: Displaying the contents of an imported module...from ENGSOL

Alex Martelli aleaxit at
Mon Aug 6 07:45:16 CEST 2001

<fleet at> wrote in message
news:mailman.997066209.23085.python-list at
> I think I'm hung up on the substitution thing again.  If I wanted to name
this '' and
> be able to use 'python math' on the command line - how do I get
"import sys.argv[1]"
> to work.  (and I would already have imported 'sys.')  I tried 'eval()'
without success - kept
> getting "invalid syntax" although the proper string was shown.

modobj = __import__(sys.argv[1])

imports the module named by sys.argv[1] and places a reference to
the resultin module object in variable modobj.

So, the loop:

> >for x in dir(os):

    for x in dir(modobj):

and so on.


More information about the Python-list mailing list