How to manipulate C table as python list ?
17 Jan
2009
17 Jan
'09
4:06 p.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 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.
5566
Age (days ago)
5567
Last active (days ago)
4 comments
4 participants
participants (4)
-
Hrvoje Niksic
-
Jack Jansen
-
Marc
-
Stefan Behnel