how exactly do binary files work in python?

Grant Edwards grante at visi.com
Mon Mar 13 05:58:36 CET 2006


On 2006-03-13, Alex Martelli <aleaxit at yahoo.com> wrote:
> Grant Edwards <grante at visi.com> wrote:
>    ...
>> > What does a binary file do that a text file doesn't, aside
>> > from not converting the end of line characters?
>> 
>> Nothing.  It's the end-of-line conversion that can break binary
>> data.
>
> I believe that a "control-Z" (ord(26)) in a file that's being read as
> text, on Windows, is also taken as an end-of-file indication.

Ah yes.  IIRC, that's left over from CP/M, where the filesystem
didn't keep a file length for files other than a block count.
It was up to the application(s) to keep track of where in that
last block the "real" data ended.

-- 
Grant Edwards                   grante             Yow!  I wonder if I ought
                                  at               to tell them about my
                               visi.com            PREVIOUS LIFE as a COMPLETE
                                                   STRANGER?



More information about the Python-list mailing list