PyArg_BuildValue, how to return a PyString object?

Kevin Cazabon kevin at cazabon.com
Mon Apr 1 23:04:20 EST 2002


I'm writing a C extension dll for Python, and am having a bit of
trouble figuring out how to return a PyString_FromStringAndSize object
(along with some normal stuff).

(I need to use PyString_FromStringAndSize because the string may
contain null bytes, am I correct in this, or is there an easier way?)

Can I use something like this (it doesn't seem to work like this
though):

PyObject *myPyStringObject = PyString_FromStringAndSize(cstringarray,
size);
PyObject *myReturnObject =  Py_BuildValue("llo", long1, long2,
myPyStringObject);

Or do I have to build a tuple manually?

Or...?


Thanks!

Kevin Cazabon.



More information about the Python-list mailing list