bugs at iter file() ?

Terry Reedy tjreedy at udel.edu
Thu Jul 15 23:17:16 EDT 2004


"Michael Geary" <Mike at Geary.com> wrote in message
news:10fc6kj98mkfef4 at corp.supernews.com...
> 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.

Sorry, but ^Z has meant end-of-file I presume from the first version of
DOS, which I suspect copied the usage from something previous.  Example
(Microsoft Basic manual, 1989): "When input is redirected [from terminal to
a file], GW Basic continues to read from this source until a CTRL-Z is
detected."  Perhaps the usage has dimmed in non-DOS-based Windows, so that
I should have said more carefully "from the viewpoint of DOS and perhaps
DOS-based Windows and partially in modern non-DOS-based Windows ...".
Still, in Windows XP, open a Command Prompt window and enter

disk:\path> copy con: temp
abd^Zdef

where ^Z is control-Z and you get a file with 3, not 7 characters.

The Windows version of the Python interactive interpreter exits on ^Z
because that is, or at least was, standard behavior for interactive non-gui
DOS/Windows programs

> 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.

This surprises me a bit.  Which version of Windows?  Try type'ing the same
file ('type filename') in an XP Home command prompt.  Even now, it should
be truncated (just tested this).

07/15/2004  11:07 PM                 7 temb
...
C:\Documents and Settings\Terry>type temb
abc

I created temb as abc^Zdef with Python file.write (^Z=\032).

> It's the C runtime that makes the distinction between text and binary
files
> and treats ^Z specially.

The Microsoft Windows C runtime treats ^Z specially because that is, or at
least was, the OS convention. possibly since before there was a C compiler
for DOS.

Terry J. Reedy






More information about the Python-list mailing list