using binary in python

Marko Rauhamaa marko at pacujo.net
Mon Nov 9 08:25:55 EST 2015


Chris Angelico <rosuav at gmail.com>:

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

So we have this stack:

  +-------------+
  | Application |
  +-------------+
  |   Python    |
  +-------------+
  |    UNIX     |
  +-------------+

The question is, does Python want to be "just a programming language"
that exposes UNIX to the application program? Or does Python want to
present an abstraction different than UNIX? IOW, is the dividing line
between the application and the operating system above or below Python?

It is evident that Python3 has intentionally moved away from the "just a
programming language" view toward Java's write-once-run-everywhere
ideal.


You would be correct that the original UNIX file system model was based
on somewhat of a naive falsity, namely text=ASCII. No matter how you
view it, there is a conflict of sorts. Python3 is trying to pave over
the conflict, but personally I would prefer the programming language
just give me the OS, warts and all.


Marko



More information about the Python-list mailing list