file.tell problems (1.5.2/Win32)
rozzin at geekspace.com
Mon Jun 28 22:17:02 EDT 1999
Greg Ewing wrote:
> Bill Wilkinson wrote:
> The problem is, tell() returns 0 at this point
> even if the file being appended to is NOT EMPTY!
> Only after something has been written does tell()
> return the correct file position.
Note the following text from the Python documentation for the open() function:
"...(which on some Unix systems means that all writes append to the end of the
file, regardless of the current
This leads me to believe that `append mode' is intended to `append' at the
*current* point in the file, which should, for consistency's sake, start at 0.
I'm guessing that the idea is: start at 0, for consistency's sake. Try to
append to the current position--if the OS believes that the append should be
done at the end, move to the end first.
If you want to make sure that you've got file.tell() returning the position of
the end of the file, just use file.seek(0, 2) immediately after open()ing the
More information about the Python-list