Using PyArg_ParseTuple to with optional fields.
anthony.flury at btinternet.com
Thu Feb 28 04:18:22 EST 2019
I am trying to write an extension module with a function (actually an
__init__ method, but I am not sure that matters) where the function can
be called as either :
my_func( a, b, c, d) - where a,b,c,d are all doubles.
I would prefer not to allow the function to be called with some
arguments specified - it is either all four - or none.
I have tried the following format strings to PyArg_ParseTuple :
* "dddd" - but this a mandatory 4 doubles - doesn't allow for the no
* "|dddd" - allows no arguments - but also allows only one, or just
two, or three - i.e. not all or nothing
* |(dddd) - allows no argument, but passing 4 arguments expects a
4-tuple - i.e. my_func( (a,b,c,d) ) which is unnecessarily complex
Can I do what I want with a single call to PyArg_ParseTuple ?
*Email* : anthony.flury at btinternet.com <mailto:Anthony.flury at btinternet.com>
*Twitter* : @TonyFlury <https://twitter.com/TonyFlury/>
More information about the Python-list