logo       

Mapping a stdio-FILE to a Python-file: msg#00052

python.pyrex

Subject: Mapping a stdio-FILE to a Python-file

Some time ago, Joachim Saul <saul@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxxx +--------------------------------------+


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise