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

2015-05-08 Thread Marko Rauhamaa
Ben Finney ben+pyt...@benfinney.id.au: Chris Angelico ros...@gmail.com writes: On Fri, May 8, 2015 at 1:24 AM, Marko Rauhamaa ma...@pacujo.net wrote: That's Python's job. Abstracting away all those differences so you don't have to look at them. That's the difference between our

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

2015-05-07 Thread Stefan Zimmermann
And last but not least, Popen behavior on Windows makes it difficult to write OS-independent Python code which calls external commands that are not binary by default: 2 examples: 1. I wrote a coffeetools package which wraps the CoffeeScript compiler in a Python API. The 'coffee' command is a

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

2015-05-07 Thread Stefan Zimmermann
Nice to see that my topic gains that interest :) And I see that I should have gone more into detail about what I'm actually trying to point out. Chris Angelico wrote: Hmm... hm... Ha! Found the difference. I had an explicit shebang on my script; yours just starts out with shell commands. That

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

2015-05-07 Thread Gisle Vanem
Chris Angelico wrote: There's a specific search order. Back in the days of DOS, it was simply com, then exe, then bat, but on modern Windowses, I think it's governed by an environment variable. You probably mean '%PATHEXT'. Mine is:

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

2015-05-07 Thread Marko Rauhamaa
Stefan Zimmermann zimmermann.c...@gmail.com: Calling an external command should be one of the simplest tasks in a high level scripting language like Python. Actually, that's quite a tricky operation in any OS. For example, bash's simplicity is a trap that claims a lot of victims. Anyway,

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

2015-05-07 Thread Stefan Zimmermann
Marko Rauhamaa wrote: Anyway, Python has os.system() that does the quick and dirty thing you might be looking for. Always invokes shell == overhead for .exe files -- https://mail.python.org/mailman/listinfo/python-list

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

2015-05-07 Thread Chris Angelico
On Fri, May 8, 2015 at 1:14 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Thu, May 7, 2015 at 8:03 AM, Chris Angelico ros...@gmail.com wrote: On Thu, May 7, 2015 at 11:44 PM, Marko Rauhamaa ma...@pacujo.net wrote: Whole programming cultures, idioms and right ways differ between platforms.

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

2015-05-07 Thread Dave Angel
On 05/07/2015 06:24 AM, Chris Angelico wrote: On Thu, May 7, 2015 at 8:10 PM, Marko Rauhamaa ma...@pacujo.net wrote: Stefan Zimmermann zimmermann.c...@gmail.com: And last but not least, Popen behavior on Windows makes it difficult to write OS-independent Python code which calls external

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

2015-05-07 Thread Marko Rauhamaa
Stefan Zimmermann zimmermann.c...@gmail.com: And last but not least, Popen behavior on Windows makes it difficult to write OS-independent Python code which calls external commands that are not binary by default: Then, write OS-dependent Python code. I don't think it's Python's job to pave

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

2015-05-07 Thread Chris Angelico
On Thu, May 7, 2015 at 8:10 PM, Marko Rauhamaa ma...@pacujo.net wrote: Stefan Zimmermann zimmermann.c...@gmail.com: And last but not least, Popen behavior on Windows makes it difficult to write OS-independent Python code which calls external commands that are not binary by default: Then,

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

2015-05-07 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: I was specifically disagreeing with the notion that it's right and normal to write a bunch of platform-specific code in Python. That should be the rarity. Why is that? Code is written for a specific need and environment. Often trying to write generic

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

2015-05-07 Thread Chris Angelico
On Fri, May 8, 2015 at 1:24 AM, Marko Rauhamaa ma...@pacujo.net wrote: That's Python's job. Abstracting away all those differences so you don't have to look at them. That's the difference between our opinions: you want Python to work the same on different OS's. I want Python's system

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

2015-05-07 Thread Ben Finney
Chris Angelico ros...@gmail.com writes: On Fri, May 8, 2015 at 1:24 AM, Marko Rauhamaa ma...@pacujo.net wrote: That's Python's job. Abstracting away all those differences so you don't have to look at them. That's the difference between our opinions: you want Python to work the same on

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

2015-05-07 Thread Chris Angelico
On Thu, May 7, 2015 at 11:44 PM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@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

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

2015-05-07 Thread Marko Rauhamaa
Chris Angelico ros...@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

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

2015-05-07 Thread Stefan Zimmermann
This discussion is getting really interesting and far beyond the actual topic :) I want to add some additional thoughts on Popen: Marko Rauhamaa wrote: Stefan Zimmermann: And last but not least, Popen behavior on Windows makes it difficult to write OS-independent Python code which calls

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

2015-05-07 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: 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

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

2015-05-07 Thread Ian Kelly
On Thu, May 7, 2015 at 8:03 AM, Chris Angelico ros...@gmail.com wrote: On Thu, May 7, 2015 at 11:44 PM, Marko Rauhamaa ma...@pacujo.net wrote: Whole programming cultures, idioms and right ways differ between platforms. What's the right way to write a service (daemon)? That's probably

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

2015-05-07 Thread Chris Angelico
On Thu, May 7, 2015 at 9:28 PM, Dave Angel da...@davea.name wrote: It's a nice goal. But these aren't OS features in Windows, they're shell features. And there are several shells. If the user has installed a different shell, is it Python's job to ignore it and simulate what cmd.exe does?

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

2015-05-07 Thread Chris Angelico
On Thu, May 7, 2015 at 10:41 PM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: I was specifically disagreeing with the notion that it's right and normal to write a bunch of platform-specific code in Python. That should be the rarity. Why is that? Code is written

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

2015-05-06 Thread Stefan Zimmermann
Hi. I don't like that subprocess.Popen(['command']) only works on Windows if there is a command.exe in %PATH%. As a Windows user you would normally expect that also command.bat and command.cmd can be run that way. There are simple workarounds like Popen(..., shell=True) but that is a heavy

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

2015-05-06 Thread Steven D'Aprano
On Thursday 07 May 2015 12:19, Chris Angelico wrote: On Thu, May 7, 2015 at 10:58 AM, Dave Angel da...@davea.name wrote: There's nothing Windows-specific about that behaviour. In Linux, there are bash commands that can only be run by using shell=True. Fortunately Popen didn't make the

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

2015-05-06 Thread Chris Angelico
On Thu, May 7, 2015 at 1:33 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thursday 07 May 2015 12:19, Chris Angelico wrote: On Thu, May 7, 2015 at 10:58 AM, Dave Angel da...@davea.name wrote: There's nothing Windows-specific about that behaviour. In Linux, there are

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

2015-05-06 Thread Dave Angel
On 05/06/2015 06:11 PM, Stefan Zimmermann wrote: Hi. I don't like that subprocess.Popen(['command']) only works on Windows if there is a command.exe in %PATH%. As a Windows user you would normally expect that also command.bat and command.cmd can be run that way. and command.com. If

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

2015-05-06 Thread Chris Angelico
On Thu, May 7, 2015 at 10:58 AM, Dave Angel da...@davea.name wrote: There's nothing Windows-specific about that behaviour. In Linux, there are bash commands that can only be run by using shell=True. Fortunately Popen didn't make the mistake of pretending it's a shell. But bash commands