[Tutor] file.read() doesn't give full contents of compressed files

Kent Johnson kent37 at tds.net
Tue Feb 20 14:29:51 CET 2007


Barton David wrote:
> Oh... of course. Thanks and sorry for missing the bleeding obvious.
> 
> Mind you, when reading in 'txt mode' rather than binary, len() actually
> gives a much *smaller* size than getsize. Does the conversion into txt
> happen to introduce some sort of terminator character that stops
> file.read() from going to the end?

Actually, yes. A ctrl-Z is treated as an end-of-file when reading a file 
in text mode on Windows.
http://groups.google.com/group/comp.lang.python/msg/4604aac0222a0043?hl=en&

Kent



More information about the Tutor mailing list