NEWBIE TIP: Displaying the contents of an imported module...from ENGSOL
aleaxit at yahoo.com
Mon Aug 6 07:45:16 CEST 2001
<fleet at teachout.org> wrote in message
news:mailman.997066209.23085.python-list at python.org...
> I think I'm hung up on the substitution thing again. If I wanted to name
this 'show.py' and
> be able to use 'python show.py math' on the command line - how do I get
> 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)
imports the module named by sys.argv 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