bugs at iter file() ?

Michael Geary Mike at Geary.com
Thu Jul 15 01:48:02 EDT 2004


Terry Reedy wrote:
> To add to what Tim said: From the viewpoint of Windows in
> its default mode, there are no remaining lines. ^Z is the end
> of file and anything after that is accidental junk filling out the
> remainder of the disk block.

Just to clarify one point... Windows itself does not have "text" or "binary"
files, and it does not treat ^Z in a file in any special way. There are no
special characters in files. A file is simply an array of arbitrary bytes
with an exact length.

For example, if you use Notepad to open a file with embedded ^Z characters,
you will see those characters in the text (typically as right arrows,
depending on the font). The file won't be truncated at the first ^Z.

It's the C runtime that makes the distinction between text and binary files
and treats ^Z specially. When you use fopen(filename,"rt") you get the
special behavior of translating CRLF pairs to LF characters and stopping at
the first ^Z.

Of course, from the point of view of a Python program, it hardly matters
whether it's Windows or the C runtime that is doing this. I just wanted to
clarify where this special behavior is taking place--it's nothing
fundamental to the operating system at all.

-Mike





More information about the Python-list mailing list