getting object instead of string from dir()

Christian Heimes lists at
Wed Dec 17 18:59:03 CET 2008

Rominsky schrieb:
> I am trying to use dir to generate a list of methods, variables, etc.
> I would like to be able to go through the list and seperate the
> objects by type using the type() command, but the dir command returns
> a list of strings.  When I ask for the type of an element, the answer
> is always string.  How do I point at the variables themselves.  A
> quick example is:
> a = 5
> b = 2.0
> c = 'c'
> lst = dir()
> for el in lst:
>     print type(el)

for name, obj in vars().iteritems():
    print name, obj


More information about the Python-list mailing list