How to receive a FILE* from Python under MinGW?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Mar 21 00:15:37 EDT 2007


En Wed, 21 Mar 2007 00:46:03 -0300, John Pye  
<john.pye at student.unsw.edu.au> escribió:

> This is not an option for me, as I want to pass the
> FILE* from Python and all the way into into a existing shared-library
> code. I can't change the latter; it must work ok with standard fprintf
> (etc) functions.

You can get the file descriptor from the Python file object using its  
fileno() method. The file descriptor lives at the OS level, so it's safe  
to pass around. You can regenerate a new FILE struct (using the other  
runtime library) with fdopen.


-- 
Gabriel Genellina




More information about the Python-list mailing list