METH_VARARGS
requires at least one argument; METH_NOARGS
doesn't seem to let me pass any at all.
How can I define a function build()
that can be called as either build()
or build(True)
/build(False)
?
Calling a METH_VARARGS
function with no arguments results in:
TypeError: function takes exactly 1 argument (0 given)
I was thinking about the problem wrong. It's not the definition, but rather the parsing that rose my TypeError.
To prevent it, I just had to use "|O"
instead of "O"
in PyArg_ParseTuple
!