A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2010-March/720774.html below:

Passing FILE * types using ctypes

Passing FILE * types using ctypes Passing FILE * types using ctypesGregory Ewing greg.ewing at canterbury.ac.nz
Fri Mar 5 03:10:01 EST 2010
Francesco Bochicchio wrote:

> Python file objects have a method fileno() whic returns the 'C file
> descriptor', i.e. the number used by low level IO in python as well as
> in C.
> I would use this as interface between python and C and then in the C
> function using fdopen to get a FILE * for an already open file for
> which you have a file descriptor.

But note that this will be a *new* stdio file buffer
attached to the same file descriptor, not the same one
that the Python file object is using. This may or may
not be a problem depending on what you're trying to
do.

If you need the same FILE * that Python is using, you
may need to use ctypes to extract it out of the file
object.

-- 
Greg

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4