Alex Martelli 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: > >>>> 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"
your test doesn't match the OP's example, though, which used control-Z to signal end of file when reading from the console: >copy con test.txt hello ^Z 1 file(s) copied. that control-Z works in the same way as control-D on Unix, and no EOF character is copied to the file: >python -c "print repr(open('test.txt', 'rb').read())" 'hello\r\n' </F> -- http://mail.python.org/mailman/listinfo/python-list