Windows vs. file.read

MRAB python at mrabarnett.plus.com
Wed Sep 1 13:31:50 EDT 2010


On 01/09/2010 18:03, Mike wrote:
> I have a ppm file that python 2.5 on Windows XP cannot read
> completely.
> Python on linux can read the file with no problem
> Python on Windows can read similar files.
> I've placed test code and data here:
> http://www.cs.ndsu.nodak.edu/~hennebry/ppm_test.zip
> Within the directory ppm_test, type
> python ppm_test.py
> The chunk size commentary occurs only if file.read cannot read enough
> bytes.
> The commentary only occurs for the last file.
> Any ideas?
> Any ideas that don't require getting rid of Windows?
> It's not my option.

You should open the files in binary mode, not text mode, ie file(path,
"rb"). Text mode is the default. Not a problem on *nix because the line
ending is newline.



More information about the Python-list mailing list