pythonfile-handling

For a newly created file, is there any difference between write() and append() methods?


For a newly created file, is there any difference between write() and append() methods, in Python?


Solution

  • When you open a file in append mode, the seek pointer points to the end of the file (the pointer position will be non-zero if the file is not empty).

    On new (empty) files, the end is equal to the beginning. So appending is the same as overwriting.