"Gary Herron" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| [EMAIL PROTECTED] wrote:
| > I want to iterate over members of a module, something like:
| >
| >     for i in dir(x):
| >         if type(i) == types.FunctionType: ...
| >
| > but of course dir() returns a list of strings.  If x is a module,
| > how can I get the list of its members as their actual types?
| >
| > Many TIA!
| > Mark
| >
| >
| Use the builtin vars to get a dictionary of names and associated objects.
|
| import sys
| for name,ob in vars(sys).items():
|  print name,type(ob)

This also works on classes, but apparently not on most other objects. 



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to