reading and writing files buffering if the buffering value is set to no buffering takes place if the buffering value is line buffering is performed while accessing file the access_mode values are given in the following table mode description opens file for reading only the file pointer is placed at the beginning of the file this is the default mode opens file for reading only in binary format the file pointer is placed at the beginning of the file this is the default mode opens file for both reading and writing the file pointer placed at the beginning of the file opens file for both reading and writing in binary format the file pointer placed at the beginning of the file opens file for writing only overwrites the file if the file exists if the file does not existcreates new file for writing opens file for writing only in binary format overwrites the file if the file exists if the file does not existcreates new file for writing opens file for both writing and reading overwrites the existing file if the file exists if the file does not existcreates new file for reading and writing opens file for both writing and reading in binary format overwrites the existing file if the file exists if the file does not existcreates new file for reading and writing opens file for appending the file pointer is at the end of the file if the file exists that isthe file is in the append mode if the file does not existit creates new file for writing opens file for appending in binary format the file pointer is at the end of the file if the file exists that isthe file is in the append mode if the file does not existit creates new file for writing opens file for both appending and reading the file pointer is at the end of the file if the file exists the file opens in the append mode if the file does not existit creates new file for reading and writing opens file for both appending and reading in binary format the file pointer is at the end of the file if the file exists the file opens in the append mode if the file does not existit creates new file for reading and writing rb rrbw wb wwba ab aabthe file object itself has several useful attributes such as file closed returns true if the file has been closed (can no longer be accessed because the close(method has been called on itfile mode returns the access mode with which the file was opened file name the name of the file the file close(method is used to close the file once you have finished with it this will flush any unwritten information to the file (this may occur because of bufferingand will close the reference from the file object to the actual underlying operating system file this is important to do as leaving reference to file open can cause problems in larger applications as typically there are only certain number of file references possible at one time and over long period of time these