0

How can i pass the default values to c extensions like 10,20 ,the below code doesn't take the values for a =10 and b =20. In below code example.py is simple a python code which is calling the c function calculate .

example.py

def Multiply:
  calculate( a=10,b =20)

calculate.c extension file

if(! PyArg_ParseTuple(args, "ii" ,&a, &b));

-----------some more code here ------
------------------------------------
Joel Vroom
  • 1,611
  • 1
  • 16
  • 30
jaysh
  • 41
  • 1
  • 6

1 Answers1

1

Those aren't default values; those are keyword arguments. As such, they're not going to be in the args tuple.

Instead, you probably want PyArg_ParseTupleAndKeywords().

Amber
  • 507,862
  • 82
  • 626
  • 550
  • could you share some example code for using above approach .I went through some code in python document But its not much clear – jaysh Sep 07 '12 at 04:23
  • I am getting the error |"more argument specifiers than keyword list entries" when used PyARG_ParseAndKeywords(). – jaysh Sep 07 '12 at 05:59