Help identifying

Skip Montanaro (montnaro@spyder.crd.ge.com)
Sun, 8 May 1994 02:47:22 GMT

I'm getting to know Python a bit. I just tried the following without the
success I expected:

import __main__
for n in dir(__main__):
try:
dir(n)
except TypeError:
print `n`, 'is not a module'

As output, I got:

'_' is not a module
'__builtin__' is not a module
'__main__' is not a module
'__name__' is not a module
'posix' is not a module
'sys' is not a module

I would have liked to seen attribute lists for those attributes of __main__
that were modules.
I imagine I got TypeErrors for all n because the result of "dir(__main__)"
is a list of strings, not a list of attributes. How do I get what I want?

Thx,

--
Skip Montanaro (montanaro@ausable.crd.ge.com)
Now working for Automatrix. Details at 11.