[Pyrex] Mapping a stdio-FILE to a Python-file

Greg Ewing greg at cosc.canterbury.ac.nz
Sun Apr 25 08:08:29 CEST 2004


Some time ago, Joachim Saul <saul at gfz-potsdam.de> wrote:

> Ideally, I would like Pyrex to directly map the file object to a
> FILE, since both are standard types in their respective languages. I
> suspect there is probably a much more "beautiful" way to achieve the
> mapping than explicitly referring to the 'f_fp'. Did I perhaps just
> overlook something really trivial?

One way to do it is this:

  cdef extern from "Python.h":
    FILE *PyFile_AsFile(object) except NULL

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+




More information about the Pyrex mailing list