PyArg_Parse for multiple returns of python on c++
Question:
I am calling python from c++ using PyObject_CallObject
as the python return only a floating point number, i can get it by:
float output_of_python;
PyObject *pValue,*pArgs;
pValue = PyObject_CallObject(pFunc, pArgs);
PyArg_Parse(pValue, "f", &output_of_python);
however, if python’s returns 2 (return first,second), which format of PyArg_Parse(pValue… should i use to assign them to 2 c++ float variables?
p/s: this one does not work: PyArg_Parse(pValue, "f,f", &output_of_python1,&output_of_python2);
Answers:
i found it, post it here for anyone needs:
In c++, in order to get 2 variables from return of python, it is
float va1,va2;
PyArg_ParseTuple(pValue, "ff", &va1,&va2);
I am calling python from c++ using PyObject_CallObject
as the python return only a floating point number, i can get it by:
float output_of_python;
PyObject *pValue,*pArgs;
pValue = PyObject_CallObject(pFunc, pArgs);
PyArg_Parse(pValue, "f", &output_of_python);
however, if python’s returns 2 (return first,second), which format of PyArg_Parse(pValue… should i use to assign them to 2 c++ float variables?
p/s: this one does not work: PyArg_Parse(pValue, "f,f", &output_of_python1,&output_of_python2);
i found it, post it here for anyone needs:
In c++, in order to get 2 variables from return of python, it is
float va1,va2;
PyArg_ParseTuple(pValue, "ff", &va1,&va2);