I am wrapping some c++ code using cython, and I am not sure what is the best best way to deal with parameters with default values.
In my c++ code I have function for which the parameters have default values. I would like to wrap these in such a way that these default values get used if the parameters are not given. Is there a way to do this?
At this point the only way that I can see to provide option parameters is to define them as part of the python code (in the def func satement in pycode.pyx below), but then I have defaults defined more than once which I don't want.
cppcode.h:
int init(const char *address=0, int port=0, int en_msg=false, int error=0);
pycode_c.pxd:
cdef extern from "cppcode.h":
int func(char *address, int port, int en_msg, int error)
pycode.pyx:
cimport pycode_c
def func(address, port, en_msg, error):
return pycode_c.func(address, port, en_msg, error)