12.5.1 File Objects

PyFileObject
This subtype of PyObject represents a Python file object.

PyTypeObject PyFile_Type
This instance of PyTypeObject represents the Python file type.

int PyFile_Check (PyObject *p)
returns true if it's argument is a PyFileObject

PyObject * PyFile_FromString (char *name, char *mode)
creates a new PyFileObject pointing to the file specified in name with the mode specified in mode

PyObject * PyFile_FromFile (FILE *fp, char *name, char *mode, int (*close)
) creates a new PyFileObject from the already-open fp. The function close will be called when the file should be closed.

FILE * PyFile_AsFile (PyFileObject *p)
returns the file object associated with p as a FILE *

PyStringObject * PyFile_GetLine (PyObject *p, int n)
undocumented as yet

PyStringObject * PyFile_Name (PyObject *p)
returns the name of the file specified by p as a PyStringObject

void PyFile_SetBufSize (PyFileObject *p, int n)
on systems with setvbuf only

int PyFile_SoftSpace (PyFileObject *p, int newflag)
same as the file object method softspace

int PyFile_WriteObject (PyObject *obj, PyFileObject *p)
writes object obj to file object p

int PyFile_WriteString (char *s, PyFileObject *p)
writes string s to file object p



guido@CNRI.Reston.Va.US