random access files random access files all the examples presented so far suggest that files are accessed sequentiallywith the first line read before the second and so on although this is (probablythe most common approach it is not the only approach supported by pythonit is also possible to use random-access approach to the contents within file to understand the idea of random file access it is useful to understand that we can maintain pointer into file to indicate where we are in that file in terms of reading or writing data before anything is read from file the pointer is before the beginning of the file and reading the first line of text would for exampleadvance the point to the start of the second line in the file etc this idea is illustrated belowwhen randomly accessing the contents of file the programmer manually moves the pointer to the location required and reads or writes text relative to that pointer this means that they can move around in the file reading and writing data the random-access aspect of file is provided by the seek method of the file objectfile seek (offsetwhencethis method determines where the next read or write operation (depending on the mode used in the open(calltakes place in the above the offset parameter indicates the position of the readwrite pointer within the file the move can also be forwards or backwards (represented by negative offsetthe optional whence parameter indicates where the offset is relative to the values used for whence are