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


Groups > comp.lang.python > #90102

Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:Windows': 0.02; 'interfaces': 0.04; 'model,': 0.05; 'say,': 0.05; '*not*': 0.07; 'amounts': 0.07; 'differently': 0.07; 'mouse': 0.07; 'subject:PEP': 0.07; 'subject:support': 0.07; 'deprecated': 0.09; 'function,': 0.09; 'high-level': 0.09; 'subject:using': 0.09; 'runs': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'gui': 0.12; 'background.': 0.14; 'language.': 0.14; 'windows': 0.15; 'apis.': 0.16; 'awesome.': 0.16; 'background,': 0.16; 'descriptors,': 0.16; 'expects': 0.16; 'fine.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'it;': 0.16; 'parts.': 0.16; 'picks': 0.16; 'qualifying': 0.16; 'restricting': 0.16; 's/he': 0.16; 'statement.': 0.16; 'subject: \n ': 0.16; 'subject:API': 0.16; 'ubuntu,': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'library': 0.18; 'module': 0.19; 'differ': 0.19; 'file,': 0.19; "python's": 0.19; 'thu,': 0.19; 'seems': 0.21; '>>>': 0.22; 'code,': 0.22; 'programming': 0.22; '(in': 0.22; 'coding': 0.22; 'cc:addr:python.org': 0.22; 'case.': 0.24; 'config': 0.24; 'keyboard': 0.24; 'module,': 0.24; 'subject: .': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'equivalent': 0.26; 'suggested': 0.26; 'defined': 0.27; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'specifically': 0.29; 'chris': 0.29; 'ideal': 0.29; 'unix': 0.29; "doesn't": 0.30; 'restrict': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'that.': 0.31; 'apparently': 0.31; 'bunch': 0.31; 'develops': 0.31; 'layer': 0.31; 'libraries': 0.31; 'linux.': 0.31; "they'll": 0.31; 'file': 0.32; 'there.': 0.32; 'probably': 0.32; 'interface': 0.32; 'run': 0.32; 'quite': 0.32; 'linux': 0.33; 'mac': 0.33; 'maybe': 0.34; 'skip:d 20': 0.34; 'subject:from': 0.34; 'could': 0.34; 'basic': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'really': 0.36; 'module.': 0.36; 'picking': 0.36; 'possible': 0.36; 'should': 0.36; 'application': 0.37; 'too': 0.37; 'generic': 0.38; 'handle': 0.38; 'whatever': 0.38; 'files': 0.38; 'pm,': 0.38; 'that,': 0.38; 'little': 0.38; 'anything': 0.39; 'you.': 0.62; 'back': 0.62; 'provide': 0.64; 'different': 0.65; 'within': 0.65; 'life': 0.66; 'services': 0.66; 'due': 0.66; 'between': 0.67; 'natural': 0.68; 'results': 0.69; 'wish': 0.70; 'physical': 0.72; 'overcome': 0.74; 'special': 0.74; '100%': 0.77; 'yourself': 0.78; '11:44': 0.84; '2015': 0.84; 'audience,': 0.84; 'back?': 0.84; 'cultures,': 0.84; 'difference.': 0.84; 'differences,': 0.84; 'different.': 0.84; 'instantly': 0.84; 'limitations,': 0.84; 'nuclear': 0.84; 'subject:skip:F 10': 0.84; 'underneath': 0.84; 'notion': 0.91; 'to:none': 0.92; 'differences': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=XwmLViD9vt41bg3U4NKYcQFbSjEsIjmBU3kMIZYlKlQ=; b=BqYKPAeU2i6TFoVrHeKsH9mugtU0hB/B5Dr2A91JBajlu6vJ46ddXo/Rqhg5QAGSb6 Z08Ro/0U4j7tOwHezLxFXTDwHvrlyjGraYl5ZD8CBL2oUkj7KujubT9vCmcPYb5qh9HU CKDmPrMZ9CnkHoPLVa9lbDqbYwzXgRa8Vkm3m26RmstX/2X3jw0ie0tPXhhMQwUU0nbw 7+USoberd8roCP5DSCoy98mYYKkAqP4falmywaLMBeyfBGsXzplCYUXF34JcxEHVUYan 94vkPjRg/tXm1FDeizFWGcgSB4bhZ1BLdzOT55RzG22kgxdLLmD+Dgn5NkjxYCEUBLlu RSKA==
MIME-Version 1.0
X-Received by 10.50.176.137 with SMTP id ci9mr4683849igc.2.1431007440064; Thu, 07 May 2015 07:04:00 -0700 (PDT)
In-Reply-To <876184jyd4.fsf@elektro.pacujo.net>
References <a0a85a0a-555f-4fff-bc1f-49873dd297c5@googlegroups.com> <554AB8A5.708@davea.name> <mailman.198.1430965194.12865.python-list@python.org> <554adcf8$0$11103$c3e8da3@news.astraweb.com> <CAPTjJmq_hpk4tNYWcip88MYo8MtyV=+Y=qR-CALFUfGTEupB9A@mail.gmail.com> <mailman.200.1430983119.12865.python-list@python.org> <1c51085e-7795-4afc-9a4c-ad8b3f3a73a6@googlegroups.com> <cff48c78-07f5-43cc-82b0-5b92a866f7a8@googlegroups.com> <87ioc4k89v.fsf@elektro.pacujo.net> <CAPTjJmoeVX8zsmCfps8FxrkVFTJv61e2Pxi9evKVm1JdE3ZPDw@mail.gmail.com> <554B4C49.7010500@davea.name> <mailman.206.1430999023.12865.python-list@python.org> <87a8xgk1ad.fsf@elektro.pacujo.net> <mailman.207.1431003199.12865.python-list@python.org> <876184jyd4.fsf@elektro.pacujo.net>
Date Fri, 8 May 2015 00:03:59 +1000
Subject Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.208.1431007449.12865.python-list@python.org> (permalink)
Lines 94
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1431007449 news.xs4all.nl 2935 [2001:888:2000:d::a6]:43370
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:90102

Show key headers only | View raw


On Thu, May 7, 2015 at 11:44 PM, Marko Rauhamaa <marko@pacujo.net> wrote:
> Chris Angelico <rosuav@gmail.com>:
>
>>> A software system is defined through its interfaces.
>>
>> And the most important interface is with a human.
>
> I barely ever program anything for the human interface.
>
>> If you want to write single-platform code, go for it; but if you want
>> to write cross-platform code, the best way is to let someone else take
>> care of the differences, abstracting them away into a nice tidy thing
>> that we call a high-level language.
>
> You suggested most software should be platform-agnostic. Now you are
> qualifying the statement.

I'm qualifying it because it's impossible to write 100%
platform-agnostic code without restricting yourself far too much; but
that doesn't mean that it isn't a worthwhile aim.

> But still, I challenge the notion that you could write a web site, game
> or application that feels natural on the XBox, iPhone, Windows PC and
> LXDE at the same time without significant amounts of
> platform-conditioned parts.

Hmm, you're picking up some very different things there. When a human
picks up an iPhone, s/he expects to use it with a touch-based
interface; I don't know what the normal UI for an Xbox is, but Xbox
users would; and the most normal interface for LXDE would be a
mouse+keyboard. The ideal UI for each of them will differ. This is the
same as coding your application differently if you expect a blind
person to use it, or if you want to make it possible to use your
program in a theatre without disturbing the audience, or any other UI
constraint you wish to concoct. That's nothing to do with platform. If
you write a program for Ubuntu, it might go onto a tablet or a
desktop, and the ideal UI for those is (in my opinion, though not
apparently in Unity's) different.

But if you design your program to be used with the same fundamental
human interface - say, a mouse and a keyboard - then you should be
able to do that the same way on many platforms. I've seen libraries
that let you build an ncurses-like interface or a full GUI window,
using exactly the same application code. It's not difficult.

>> I don't need forking, file descriptors, or process IDs, to describe
>> how a person uses my code. Those are *implementation details*.
>
> Even if I programmed for the human and the UI experience were
> more-or-less identical between platforms, the system interfaces can be
> conceptually quite different. Heroic attempts have been made to overcome
> those differences with generic APIs. However, Python should stay out of
> that crusade.
>
> Whole programming cultures, idioms and "right ways" differ between
> platforms. What's the right way to write a service (daemon)? That's
> probably completely different between Windows and Linux. Linux itself is
> undergoing a biggish transformation there: an exemplary daemon of last
> year will likely be deprecated within a few years.

And that's where a library function can be really awesome. What's the
right way to daemonize? "import daemonize; daemonize.daemonize()"
seems good to me. Maybe there's platform-specific code in the
*implementation* of that, but in your application, no. That's the job
of a layer underneath you.

Incidentally, the way I'm seeing things shift these days is mainly
toward *not* daemonizing your services at all. That makes life a lot
easier; instead of writing special code to put yourself in the
background, you just write your code to the standard basic "glass
teletype" model, and then add a little config file that makes it run
in the background. But a Python module could provide a generic
"install as service" function, which will create a systemd config
file, or a Windows service whatever-it-is, or the equivalent on a Mac,
or an Upstart job file, or whatever it detects. Same difference. A
library takes care of all of that.

In Python, we have the 'subprocess' module. Due to Windows
limitations, you have to restrict yourself to having an importable
main file if you want perfect cross-platform compatibility, but that
doesn't affect how your code runs on Linux or Mac OS. What's the best
way to farm work off to a bunch of processes and have them communicate
their results back? You use the subprocess module, and then it doesn't
matter whether they use Unix sockets, named pipes, physical files on
the disk, or miniature nuclear explosions, they'll communicate back
just fine. And when someone develops a new platform that uses nuclear
fusion instead of fission for interprocess communication, Python's
standard library gets enhanced, and your code instantly works - you
don't have to specifically handle the new case.

That's Python's job. Abstracting away all those differences so you
don't have to look at them.

ChrisA

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


Thread

PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Stefan Zimmermann <zimmermann.code@gmail.com> - 2015-05-06 15:11 -0700
  Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Dave Angel <davea@davea.name> - 2015-05-06 20:58 -0400
  Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-07 12:19 +1000
    Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-07 13:33 +1000
      Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-07 13:57 +1000
      Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Gisle Vanem <gvanem@yahoo.no> - 2015-05-07 09:15 +0200
        Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Stefan Zimmermann <zimmermann.code@gmail.com> - 2015-05-07 02:38 -0700
          Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Stefan Zimmermann <zimmermann.code@gmail.com> - 2015-05-07 03:03 -0700
            Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Marko Rauhamaa <marko@pacujo.net> - 2015-05-07 13:10 +0300
              Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-07 20:24 +1000
              Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Dave Angel <davea@davea.name> - 2015-05-07 07:28 -0400
              Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-07 21:43 +1000
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Marko Rauhamaa <marko@pacujo.net> - 2015-05-07 15:41 +0300
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-07 22:53 +1000
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Marko Rauhamaa <marko@pacujo.net> - 2015-05-07 16:44 +0300
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-08 00:03 +1000
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Marko Rauhamaa <marko@pacujo.net> - 2015-05-07 18:24 +0300
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Stefan Zimmermann <zimmermann.code@gmail.com> - 2015-05-07 08:45 -0700
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Marko Rauhamaa <marko@pacujo.net> - 2015-05-07 21:13 +0300
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Stefan Zimmermann <zimmermann.code@gmail.com> - 2015-05-07 16:27 -0700
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-08 11:50 +1000
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Ben Finney <ben+python@benfinney.id.au> - 2015-05-08 12:26 +1000
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Marko Rauhamaa <marko@pacujo.net> - 2015-05-08 09:14 +0300
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-07 09:14 -0600
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-08 11:46 +1000

csiph-web