Python: Is there a way to reflectivly list all attributes of a class

Posted by hhafez on Stack Overflow See other posts from Stack Overflow or by hhafez
Published on 2010-04-10T04:36:30Z Indexed on 2010/04/10 4:43 UTC
Read the original article Hit count: 226

Filed under:
|
|

Given a class such as

def MyClass
    text = "hello"
    number = 123

Is there a way in python to inspect MyClass an determine that it has the two attributes text and number. I can not use something like inspect.getSource(object) because the class I am to get it's attributes for are generate using SWIG (so they are hidden in .so :) ).

So I am really looking for something equivalant to Java's [Class.getDeclardFields][1]

Any help would be appreciated, otherwise I'll have to solve this problem with SWIG + JAVA instead of SWIG + Python.

© Stack Overflow or respective owner

Related posts about python

Related posts about reflection