SOLVED: Write \x1a to binary file

Steve Holden sholden at holdenweb.com
Wed Jul 24 11:23:32 EDT 2002


"Harald Schneider" <h_schneider at marketmix.com> wrote in message
news:ah1jph$jab$03$1 at news.t-online.com...
> Thanks a lot!
>
> I was a little bit fast with my request. Due to a bug, the end of my file
> was overwritten, so that the end marker \x1a was deleted.
> In fact, it is sufficient to open the file with mode 'b' to write all kind
> of binary data (on Win32, running Active Python 2.1).
>
> BUT:
> One strange side effect, I recogniced ...
> - I write \x1a to the end of a file.
> - I close it and reopen in text mode
>  The result: the last byte gets cut off ... even when nothing is written
to
> that file!
>

This is maybe an old thread, so perhaps you've already realized that \x1a is
CTRL/Z, which DOS-based systems recognize as terminating a text file.

regards
-----------------------------------------------------------------------
Steve Holden                                 http://www.holdenweb.com/
Python Web Programming                http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------








More information about the Python-list mailing list