Jan. 18, 2009
12:06 a.m.
Hi,
I would like to use a C program which manipulates table as a python module acting on a list. My C code is the following: int sum(int *tab, int n) { int i, s = 0;
for (i=0; i<n; i++) { s += tab[i]; }
return s; } Now, I would like to use it as a python module where tab would be a python list. I read some examples in the documentation but the size of the list is always assumed to be known such that one can use PyArg_ParseTuple with a format description for each argument. I would like that my module behave like: a=[1,2,3] b=[2,8,20] print my_module.sum(a) -> 6 print my_module.sum(b) -> 30
My question is: which option should I use with PyArg_ParseTuple? I'm totaly lost with all its option (O, O&, O!, etc)
Thx, Marc.