Python ctypes: Python file object <-> C FILE * -


I am using ctypes to wrap the c-library with Python (which is in my control). I want to wrap a function with the declaration:

  int fread_int (FILE * stream);  

now; I would like to open the file in Python, and then use the Python file object (somehow ??) to get access to the built-in FILE * object and pass that c-function:

  # Python file H = open (file, "R") value = ctypes_function_fread_int (?????) fileH.close ()  

What is the Python file & lt; -> FILE * Mapping all possible?

Joakim

I have encountered the same problem

View this file:

You can use PyFile_AsFile from it.


Comments