string reading bug in ActiveState Python 2.2 ?
hst at empolis.co.uk
Tue Sep 3 11:05:24 CEST 2002
Axel Kowald wrote:[mailto:kowald at molgen.mpg.de]
> I'm using ActiveStates Python 2.2.1 under win2000 to read in the
> attached text file and it seems that python is only reading
> part of the
> string. After
> fp = open("bla.txt")
> z = fp.read()
> print len(z), z
> I see that only 11 of the 15 characters have been read. I
> know they are
> non-printable characters, but that shouldn't matter, should
> it ? Using
> another python on one of our unix machines everything works
> as expected
> and all 15 chars are read in. Is that there something special about
> windows that I should know, or is this a bug in ActiveStates Python ?
> Many thanks,
> Axel Kowald
The 12th of the fifteen characters is \x1a which is EOF on Windows in text mode (the default).
Use fp = open("bla.txt", 'rb') and you will read all 15 characters.
This message has been checked for all known viruses by the MessageLabs Virus Scanning Service.
More information about the Python-list