embedding; return array
Fredrik Lundh
Fredrik.Lundh at p98.f112.n480.z2.fidonet.org
Fri Jul 2 04:02:06 EDT 1999
More information about the Python-list mailing list
Fri Jul 2 04:02:06 EDT 1999
- Previous message (by thread): embedding; return array
- Next message (by thread): TIFF-images
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: "Fredrik Lundh" <fredrik at pythonware.com> Randy Heiland wrote: > I'd welcome any pointers into being able to return an (unsigned char) > array from an embedded module. how about: return Py_BuildValue("s#", buffer, buffer_size); (gives you a string; you can use the array module to process it further). if you really want to return it as a python list, you have to build the list yourself. something like: PyObject* list; list = PyList_New(buffer_size); if (list) for (i = 0; i < buffer_size; i++) { PyObject* item; item = PyInt_FromLong(buffer[i]); if (item == NULL) { Py_DECREF(list); list = NULL; break; } PyList_SetItem(list, i, item); } } return list; should do the trick. </F>
- Previous message (by thread): embedding; return array
- Next message (by thread): TIFF-images
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list