next up previous contents
Next: Standard Input and Output Up: File Objects Previous: Other Methods   Contents

File Object Variables

Along with the methods described above, file objects also contain several variables, often refered to as attributes, containing information about the file which the file object represents. These attributes are accessed just like methods, except that, since they are variables, they accept no arguments, and need no parentheses when accessed. The name attribute is a character string containing either the name of the file or a description of its source. The closed attribute is an integer variable which is 1 if the file is closed, and 0 if the file is open. The mode attribute is a variable containing a character string, similar to the one passed to open indicating the mode through which the file was opened. Each of these attributes is read-only, and attempts to change them will result in a TypeError.

Phil Spector 2003-11-12