Python array --> C

Randy Heiland heiland at ncsa.uiuc.edu
Tue Jul 6 23:52:23 EDT 1999


In my continuing quest to better understand embedding/extending, I have
the following question...

in Demo/embed, I have modified demo.c so that the static module
xyzzy_foo(self, args)
now does the following (instead of returning 42L):
{
        unsigned char retval[5] = {0,2,4,8,16};
        return Py_BuildValue("s#", retval,5);
}
i.e., it returns an array of unsigned chars.

>From main(), I would like to invoke xyzzy.foo() and get this array of
unsigned chars into a C array.
How do I do this?  I assume I'll need to use PyRun_String(...) somehow -
true?

thanks,
--Randy





More information about the Python-list mailing list