Accessing members of Python class from C++ (Embedded Python)????
JM
jgerard at fluid-studios.ca
Tue Aug 26 19:02:21 EDT 2003
Hello everyone,
Does anybody know about, have documentation on, or have any code
samples on how to access class members from a python class in C++.
Say I have a simple python script:
---------------------------
class Animal:
NumLegs = 5
Size = 4.5
---------------------------
How exactly do you access these members from C++. I know how to get
the member if I know its name, ie.
pkObject = PyDict_GetItemString(pkDict, "Animal");
int uiNumLegs = PyInt_AsLong(PyObject_GetAttrString(pkObject,"NumLegs"));
But how do you iterate through all the class members and print their
names and values? This is easy to do for basic variables, but I can't
seem to do it for class variables.
Any help would be much apprecited. This is driving me nuts.
JG
More information about the Python-list
mailing list