0

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)
Fredrick Brennan
  • 7,079
  • 2
  • 30
  • 61

1 Answers1

0

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!

Fredrick Brennan
  • 7,079
  • 2
  • 30
  • 61