Py_BuildValue() and C++ arrays
rasmussn at lanl.gov
rasmussn at lanl.gov
Thu Apr 4 18:07:13 EST 2002
On Thursday, April 4, 2002, at 01:37 AM, Matthias Stern wrote:
> I want to return the values "numElem" (int), "unit" (char[250]) and the
> array "data" (float,10000).
> What is the correct syntax for "Py_BuildValue( ??? )" ?
>
> The first two parameters work e.g. this way:
> ---
> :
> Py_BuildValue("(si)", unit, numElem);
> :
> ---
I've used something like this before a tuple filled with an array:
PyObject* tuple = PyTuple_New(count);
for (int i = 0; i < count; i++) {
double rVal = data[i];
PyTuple_SetItem(tuple, i, Py_BuildValue("d", rVal));
}
return tuple;
Cheers,
Craig
More information about the Python-list
mailing list