la********@gmail.com wrote:
Let's say I have a python function do some math like the following:
def doMath(self):
self.val = self.val + 1
How can I call this python function from C++? Assuming I have some sort
of Python wrapper around my C++ codes.
See the "Embedding and Extending" tutorial. In short, you write
resultObj = PyObject_CallMethod(selfObj, "doMath", "");
if (resultObj == NULL)
return NULL;
Py_DECREF(resultObj); // resultObj should be Py_None
How you get hold of self depends on your application.
Regards,
Martin