C Module question

greg greg at cosc.canterbury.ac.nz
Mon Nov 10 23:01:04 EST 2008


boblatest at googlemail.com wrote:
> Sadly this doesn't work on "file-like"
> objects like those that are created by opening bz2 files (using the
> bz2 lib).

If the C code you're calling requires a FILE *, then you're
out of luck. There's no way of getting a FILE * from an object
that's not based on an actual PyFile object, since there
simply isn't one to be had.

There is an exception to that -- if the object is one that
has a file descriptor underlying it somewhere (such as a
pipe or socket) you could get that and wrap it using fdopen().

-- 
Greg



More information about the Python-list mailing list