file IO

Darren Dale dd55 at cornell.edu
Tue Aug 3 19:30:51 CEST 2004


Jeff Epler wrote:
> Are you using Windows?  That would mean the answer is almost certainly
> "something to do with carriage returns and binary vs text mode".  The
> lack of a trailing newline on the last line of your example can also
> make for additional trouble (though my tests on unix, with stdio, mmap,
> and StringIO didn't ever give me a 4-byte file, windows might give you
> the file "a\r\nb" when viewed in binary format, "a\nb" when viewed in
> text format)
> 
> I doubt that the mmap module's readline knows whether the file was
> opened in universal text mode---that's a pure Python invention, while
> mmap takes a file descriptor.
> 

I am using windows (for now), and reading files created on a Linux 
machine. I think you are right, it has something to do with mmap and the 
/r/n windows convention. Thank you (very much) for your response... I am 
sane again.

Darren



More information about the Python-list mailing list