python to c API, passing a tuple array

imdognuts at yahoo.com imdognuts at yahoo.com
Fri Apr 14 19:03:37 EDT 2006


Hi,
I want to pass something like this to a C function via the Python C
API.
mytuple = (("string_one", 1.2, 1.3), ("string_two", 1.4, 1.5), ......,
.....,  )
This tuple is dynamic in size, it needs to be 3 X N dimensions. each
tuple in the
tuple array is of the form (string, float, float) as described above

so from python:

mytuple = (("string_one", 1.2, 1.3), ("string_two", 1.4, 1.5))
api.myCFunction(mytuple)

The C api:
static PyObject *myCFunction(PyObject *self, PyObject *args)
{

    if (!PyArg_ParseTuple(args, "O", ..... ?????????????)  {
        printf(" error in PyArg_ParseTuple!\n");
        return Py_None;
    }

Thanks.




More information about the Python-list mailing list