passing FILE pointers to a non-MSVC++ compiled extension type???

Alex Martelli aleaxit at yahoo.com
Fri Aug 10 06:16:52 EDT 2001


"doug" <doug_bartholomew99 at yahoo.com> wrote in message
news:e71960c5.0108091604.3b2f589f at posting.google.com...
> hello,
>
> bottomline:
> is there someway i can write an extenstion type's print method so that
> instead of fprintf-ing to the FILE* directly, i call back to some
> python c api function with the c string of what i want to print???

Yes, PyFile_WriteString should serve your purposes (you'll pass
your C-like string as a char* first argument, a PyObject* for the
relevant Python file-like object as the second argument -- there's
a bug in the docs, they mention an unexplained third 'flags'
argument, but fileobject.h and fileobject.c show there is nothing
of the kind -- I've just submitted a correction to sourceforge).


Alex






More information about the Python-list mailing list