[capi-sig] Py_BuildValue, Array from C to Python

Jon Parise jon at indelible.org
Fri Jan 16 18:41:37 CET 2009


On Fri, Jan 16, 2009 at 8:34 AM, Philipp Heuser <philipp at achtziger.de> wrote:

> I am trying to return an array from C to Python. Since it is of variable
> size,
>
> return Py_BuildValue("[f,f,f]", array[0], array[1], array[2]);
>
> does not help. How do I do that?

Try creating a Python tuple or list in your C function and returning
that object instead.  You can read about those C API functions here:

   http://docs.python.org/c-api/tuple.html
   http://docs.python.org/c-api/list.html

-- 
Jon Parise (jon of indelible.org)  ::  "Scientia potentia est"


More information about the capi-sig mailing list