I'm trying to create a python module using my C++ code and I want to declare a function with multiple arguments. (3 in this case) I've read the docs and it says that I must declare METH_VARARGS which I did, but I think I also must change something inside my function to actually receive the arguments. Otherwise it gives me "too many arguments" error when I use my function in python.
Here is the code snippet I'm using:
...
// This function can be called inside a python file.
static PyObject *
call_opencl(PyObject *self, PyObject *args)
{
const char *command;
int sts;
// We except at least one argument to this function
// Not sure how to accept more than one.
if (!PyArg_ParseTuple(args, "s", &command))
return NULL;
OpenCL kernel = OpenCL();
kernel.init();
std::cout << "This message is called from our C code: " << std::string(command) << std::endl;
sts = 21;
return PyLong_FromLong(sts);
}
static PyMethodDef NervebloxMethods[] = {
{"call_kernel", call_opencl, METH_VARARGS, "Creates an opencv instance."},
{NULL, NULL, 0, NULL} /* Sentinel */
};
...