Returning list of arrays from C

Randall Hopper aa8vb at yahoo.com
Wed Dec 29 12:31:57 EST 1999


Curtis Jensen:
 |I need to return a list of arrays from a CAPI.  I'm using the Numeric
 |module to create some C extensions.  Though, I need to return several
 |arrays to Python.  How can I do this?

You can start with something like this:

    target = PyList_New( verts->length );
    for ( i = 0; i < vertes->length; i++ )
      PyList_SetItem( target, i, 
                      PyFloat_FromDouble( (double) verts->vertices[i] ) );

Add error checking, and modify to taste using the C API reference guide:

    http://www.python.org/doc/current/api/api.html


-- 
Randall Hopper
aa8vb at yahoo.com




More information about the Python-list mailing list