Pass a tuple (or list) to a C wrapper function
Jeremy Moles
jeremy at emperorlinux.com
Wed Oct 12 17:27:35 EDT 2005
It depends on how you want to manipulate the data in C. If you want
compile-time variable access to each float, yeah, 50 floats. :)
Probably what you want to do though is just keep the tuple as is and
iterate over it using the PySequence_* protocol:
http://docs.python.org/api/sequence.html
On Wed, 2005-10-12 at 13:06 -0700, Java and Swing wrote:
> I have a C function which takes an array of long values..
>
> I understand that I can pass a tuple to a C wrapper function and in the
> C wrapper function have..
>
> int ok = PyArg_ParseTuple(args, "s(ll)", &a, &b, &c);
>
> ..that's great if my tuple only contained two longs..but what if it
> contained 50
> would I have to do..
>
> int ok = PyArg_ParseTuple(args, "s(llllllllllllllllll....ll)", &a, &b,
> &c, &d...) ??
>
> how can I handle this?
>
More information about the Python-list
mailing list