Accessing members of Python class from C++ (Embedded Python)????
Greg Chapman
glc at well.com
Thu Aug 28 10:12:04 EDT 2003
On 27 Aug 2003 10:14:02 -0700, jgerard at fluid-studios.ca (JM) wrote:
>If anyone is interested in the solution:
>
>pDict=PyObject_GetAttrString(PyObject,"__dict__") will get the local
>symbol table (a dictionary) for the class.
This may not be relevant to your needs, but a class's __dict__ only has
references to the attributes actually declared in the class; it doesn't have
inherited attributes. If you need access to all the attributes of a class, use
PyObject_Dir(aClass), which returns a list of all attribute names declared in
the class and it's superclasses (it's the C equivalent of the dir builtin). You
can then use PyObject_GetAttr(aClass, attrname) to fetch the attributes
themselves.
---
Greg Chapman
More information about the Python-list
mailing list