156135250194107072078175030179198180024228156016206217188240240204175207178022223037158122
File Built-in Attributes
File objects also have data attributes in addition to its methods. These attributes hold auxiliary data related to the file object they belong to, such as the file naFme (file.name), the mode with which the file was opened (file.mode), whether the file is closed (file.closed), and a flag indicating whether an additional space character needs to be displayed before successive data items when using the print statement (file.softspace).Table 9.4 lists these attributes along with a brief description of each.
Table 9.4. Attributes for File Objects
File Object Attribute |
Description |
file.closed |
1 if file is closed, 0 otherwise |
file.mode |
access mode with which file was opened |
file.name |
name of file |
file.softspace |
0 if space explicitly required with print, 1 otherwise; rarely used by the programmer—generally for internal use only |
| Last updated on 9/14/2001 Core Python Programming, © 2002 Prentice Hall PTR |
|