On Thu, May 31, 2018 at 9:34 AM, Cameron Simpson <c...@cskk.id.au> wrote: > On 30May2018 21:29, MRAB <pyt...@mrabarnett.plus.com> wrote: >> >> On 2018-05-30 21:01, Paul St George wrote: >>> >>> Is this equivalent? >>> p = subprocess.Popen('display', + imagepath) >>> >> p = subprocess.Popen(['display', imagepath]) >> >>> so >>> >>> p = subprocess.Popen('display', 'test.png') >>> >> p = subprocess.Popen(['display', 'test.png']) >> >> Remembering to provide the full paths (unless it's/they're on the system's >> search path). > > > Personally, I am generally against the "use a full path" advice. > > Using a full path to the executable is (a) nonportable because executables > may be in different places on different systems and (b) obstructive to the > user, because they may have built or installed their own version of the app > for specific purposes, such as the vendor provided version being out of > date. > > For example, Paul's problem might also be addressable by writing his own > "display" shell script invoking the tool of his choice. Like Python, the > executable command name is a dynamic lookup! > > IMO it is the programme caller's task to provide the execution environment, > and the programme should expect $PATH (UNIX execution search path) to be > suitable already. > > Every hardwired path is a maintenance and fragility nightmare.
Bless you, it all depends! [1] A hardwired path is safe against someone externally messing with your script. But a pathless name allows you to make use of externally-configured $PATH. Sometimes you want the safety; sometimes you want the flexibility. Using just the name is very similar to typing the command at the shell, but it's not identical to that either; shell aliases can mean that typing "grep foo bar" is not the same as "`which grep` foo bar". So it's that bit harder to explain, and you HAVE to want the behaviour that it gives. Make an intelligent decision as to whether you want a hard-coded path or just a name. ChrisA [1] I'm on the wrong mailing list to expect everyone to recognize that line. It's from "The Mikado" by Gilbert & Sullivan. -- https://mail.python.org/mailman/listinfo/python-list