I am working on a project which requires Python with C integration. I have got it mostly working except for one issue below: How do I get the string representation of the callback function object in the C code. (See my comment in the code)
import mymodule
c=0
def double_it():
c = c * 2
return
def multiply(a, b):
global c
c = a*b
mymodule.print_result(c, double_it)
return
Where mymodule.print_result
is defined as:
static PyObject*
print_result(PyObject* self, PyObject* args)
{
PyObject *pCallBackFunc, *pArgs;
int restult;
char *func_name = NULL; // I want to fill this
if (!PyArg_ParseTuple(args, "iO", &result, &pCallBackFunc))
{
printf ("ERRPR\n");
return NULL;
}
if (PyCallable_Check(pCallBackFunc)) {
Py_XINCREF(pCallBackFunc);
// func_name = .... How to get the of the call back function that is "double_it" ???
PyObject_CallObject(pCallBackFunc, pArgs);
Py_XDECREF(pCallBackFunc);
return Py_None;
}
Any help is greatly appreciated.