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()

or

    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
   argument scenario
 * "|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  ?

--
Anthony Flury
*Email* : anthony.fl...@btinternet.com <mailto:anthony.fl...@btinternet.com>
*Twitter* : @TonyFlury <https://twitter.com/TonyFlury/>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to