File Objects

File Attributes

  • The following attributes provide additional file information
     f.closed                # Set to 1 if file object has been closed
     f.mode                  # I/O mode of the file
     f.name                  # Name of file if created using open().
                             # Otherwise, a string indicating the source
     f.softspace             # Boolean indicating if extra space needs to be
                             # printed before another value when using print.

Other notes

  • File operations on lines are aware of local conventions (\n\r vs. \n).
  • String data read and written to files may contain embedded nulls and other binary content.
<<< O'Reilly OSCON 2000, Advanced Python Programming, Slide 34
July 17, 2000, beazley@cs.uchicago.edu
>>>