using binary in python

Chris Angelico rosuav at gmail.com
Mon Nov 9 06:04:26 EST 2015


On Mon, Nov 9, 2015 at 9:56 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> One of the principal UNIX innovations was to see files as simple byte
> sequences. The operating system would place no semantics on the meaning
> or structure of the bytes.

And you also want to see those files as containing "plain text",
right? Unfortunately, those two goals are in conflict. Either a file
is nothing but bytes, or it contains text in some encoding. From the
file system and operating system's points of view, the files are
indeed nothing but bytes; but from the application's point of view,
text is text and bytes is bytes. In Python, a text file is opened with
a specific encoding, and Python handles the encode/decode steps.

ChrisA



More information about the Python-list mailing list