Trouble with file.seek/file.tell on Win32?

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Mon Aug 16 13:12:54 CEST 2004


On Mon, 16 Aug 2004 00:34:47 -0400, rumours say that Prabhu Ramachandran
<prabhu at aero.iitm.ernet.in> might have written:

>I'm happy to also learn that bad line endings break tell and
>seek.  I guess this is a problem on the mac too where lines end with
>'\r'.  Is this true of OSX?

I have little knowledge of OS/X (just playing around with a friends
Apple laptop, can't remember the type), but I assume that there will not
be a problem with OS/X (and do they use '\r' like in the old MacOS, or
do they respect the Linux heritage and use '\n' now?  maybe a mix?).

The string "hello\nthere\n" written to a *text* file, has:

12 bytes on *nix
14 bytes on Windows/DOS
12 bytes on OS/X

To read the "t" of "there", one first has to:

f.seek(6) on both *nix and OS/X, text or binary file
f.seek(6) on Win text file
f.seek(7) on Win binary file.
-- 
TZOTZIOY, I speak England very best,
"Tssss!" --Brad Pitt as Achilles in unprecedented Ancient Greek



More information about the Python-list mailing list