On 2006-08-21, Alex Martelli <[EMAIL PROTECTED]> wrote: > Grant Edwards <[EMAIL PROTECTED]> wrote: > ... >> IIRC, ctrl-Z is not used _in_files_ to represent EOF. Only >> when text is being entered at the console. > > Easy to test, if you have Windows:
I might, but I won't admit it in public. :) >>>> n='foo.txt' >>>> s='ba\r\n'+chr(26)+'bo\r\r' >>>> open(n,'wb').write(s) >>>> ss=open(n).read() >>>> ss > 'ba\n' > > As you see, in _text_ files on Windows a control-Z (char(26), AKA > '\x1a') does indeed represent "end of file" -- a convention going back > to CP/M (which lacked metadata to represent file length except in > multiples of 256 characters, if I recall correctly) That's correct. > and is still followed by Windows (and by Python running on > Windows). Very interesting. I thought that windows had abandoned that. I remember having problems under DOS/Windows caused by an old text editor that put a ctrl-Z at the end of the file -- probably a result of the other programs reading the file in binary mode and seeing the ctrl-Z. > Nevertheless I doubt it would help the original poster -- I > think, like /F and you, that a line-end and flush may be what > he needs. -- Grant Edwards grante Yow! Am I elected yet? at visi.com -- http://mail.python.org/mailman/listinfo/python-list