C Module question

Floris Bruynooghe floris.bruynooghe at gmail.com
Mon Nov 10 08:23:55 EST 2008


On Nov 10, 1:18 pm, Floris Bruynooghe <floris.bruynoo... at gmail.com>
wrote:
> On Nov 10, 11:11 am, "boblat... at googlemail.com"
>
> <boblat... at googlemail.com> wrote:
> > 1. How can I pass a file-like object into the C part? The PyArg_*
> > functions can convert objects to all sort of types, but not FILE*.
>
> Parse it as a generic PyObject object (format string of "O" in
> PyArg_*), check the type and cast it.  Or use "O!" as format string
> and the typechecking can be done for you, only thing left is casting
> it.
>
> Seehttp://docs.python.org/c-api/arg.htmlandhttp://docs.python.org/c-api/file.html
> for exact details.

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.


Floris



More information about the Python-list mailing list