sequencesstringslistsand files file processing the exact details of file-processing differ substantially among programming languagesbut virtually all languages share certain underlying file manipulation concepts firstwe need some way to associate file on disk with an object in program this process is called opening file once file has been openedit' contents can be accessed through the associated file object secondwe need set of operations that can manipulate the file object at the very leastthis includes operations that allow us to read the information from file and write new information to file typicallythe reading and writing operations for text files are similar to the operations for text-basedinteractive input and output finallywhen we are finished with fileit is closed closing file makes sure that any bookkeeping that was necessary to maintain the correspondence between the file on disk and the file object is finished up for exampleif you write information to file objectthe changes might not show up on the disk version until the file has been closed this idea of opening and closing files is closely related to how you might work with files in an application program like word processor howeverthe concepts are not exactly the same when you open file in program like microsoft wordthe file is actually read from the disk and stored into ram in programming terminologythe file is opened for reading and the contents of the file are then read into memory via file reading operations at this pointthe file is closed (again in the programming senseas you "edit the file,you are really making changes to data in memorynot the file itself the changes will not show up in the file on the disk until you tell the application to "saveit saving file also involves multi-step process firstthe original file on the disk is reopenedthis time in mode that allows it to store information--the file on disk is opened for writing doing so actually erases the old contents of the file file writing operations are then used to copy the current contents of the in-memory version into the new file on the disk from your perspectiveit appears that you have edited an existing file from the program' perspectiveyou have actually opened fileread its contents into memoryclosed the filecreated new file (having the same name)written the (modifiedcontents of memory into the new fileand closed the new file working with text files is easy in python the first step is to create file object corresponding to file on disk this is done using the open function usuallya file object is immediately assigned to variable like this open(here name is string that provides the name of the file on the disk the mode parameter is either the string "ror "wdepending on whether we intend to read from the file or write to the file for exampleto open file called "numbers datfor readingwe could use statement like the followinginfile open("numbers dat"" "now we can use the file object infile to read the contents of numbers dat from the disk python provides three related operations for reading information from file