En Mon, 10 Nov 2008 11:44:44 -0200, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió:

On Nov 10, 2:23 pm, Floris Bruynooghe <[EMAIL PROTECTED]>
wrote:

Sorry, I probably should have mentioned you want to cast the object to
PyFileObject and then use the PyFile_AsFile() function to get the
FILE* handle.

Yes, I figured that out by now. Sadly this doesn't work on "file-like"
objects like those that are created by opening bz2 files (using the
bz2 lib). Not that I have any idea on how that should work anyway.

Call the file-like methods as you would with any other object method. That is, if you got an object `fobj` from Python and you want to write a C string:

        char* str="some text\n";
        PyObject_CallMethod(fobj, "write", "s", str)

See also PyObject_CallObject and the other variants: http://docs.python.org/c-api/object.html#PyObject_Call

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to