Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98538

Re: using binary in python

From Marko Rauhamaa <marko@pacujo.net>
Newsgroups comp.lang.python
Subject Re: using binary in python
Date 2015-11-09 17:46 +0200
Organization A noiseless patient Spider
Message-ID <87lha7goqi.fsf@elektro.pacujo.net> (permalink)
References (3 earlier) <mailman.169.1447067069.16136.python-list@python.org> <8737wfi9ss.fsf@elektro.pacujo.net> <mailman.174.1447077141.16136.python-list@python.org> <87si4fgs5f.fsf@elektro.pacujo.net> <mailman.179.1447082283.16136.python-list@python.org>

Show all headers | View raw


Chris Angelico <rosuav@gmail.com>:

> On Tue, Nov 10, 2015 at 1:32 AM, Marko Rauhamaa <marko@pacujo.net> wrote:
>> Yes, and lists and dicts and ints and objects and all. No problem
>> there.
>>
>> However, when filenames and sys.stdin deal with text, things are
>> getting iffy.
>
> So where do you mark the boundary between the human and the OS? If I
> create a GUI, I should be able to put an entry field down that accepts
> Unicode text. And if I make a web form and an HTTP server, a user
> should be able to type Unicode text into an <input> field and send
> that along. Either way, my program should get a Unicode string. Why
> shouldn't I be able to do the same with input()? And why, if a user
> enters a plausible file name, should that not be able to be opened as
> a file?

sys.stdin is not (primarily) a human interface. It is the canonical
channel to relay the input data to the program. The results of the
computation are emitted through sys.stdout.

The input data could well be, say, UTF-8-encoded plain text, or a PDF
file, or a Zip file, or a music recording.

As for file names, even UTF-8 Linux environments often contain filenames
that are illegal UTF-8. Using surrogate characters is a clever trick,
but might even lead to security risks when more than one pathname can
map to the same surrogate encoding.

> At what point do you say "this is for humans, this is for machines"?
> Isn't it Python's job to spare us that hassle?

Python is certainly trying to do that.

   Flik: I was just trying to help.
   Mr. Soil: Then help us; *don't* help us. 

   <URL: http://www.imdb.com/title/tt0120623/quotes>


I program for Linux. I use different programming languages, but the
target is Linux. The systems I build and deal with consist of different
components written in different programming languages but they all
follow Linux-y conventions to work harmoniously together. I don't in any
way benefit from a smoke screen a programming language offers to place
in front of the operating system.


Marko

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: using binary in python Michiel Overtoom <motoom@xs4all.nl> - 2015-11-09 11:40 +0100
  Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 12:56 +0200
    Re: using binary in python Chris Angelico <rosuav@gmail.com> - 2015-11-09 22:04 +1100
      Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 15:25 +0200
        Re: using binary in python Chris Angelico <rosuav@gmail.com> - 2015-11-10 00:52 +1100
          Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 16:32 +0200
            Re: using binary in python Chris Angelico <rosuav@gmail.com> - 2015-11-10 02:17 +1100
              Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 17:46 +0200
                Re: using binary in python Chris Angelico <rosuav@gmail.com> - 2015-11-10 02:57 +1100
                Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 18:17 +0200

csiph-web