9.4. 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 AttributeDescription
file.closed1 if file is closed, 0 otherwise
file.modeaccess mode with which file was opened
file.namename of file
file.softspace0 if space explicitly required with print, 1 otherwise; rarely used by the programmer—generally for internal use only

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset