On Thu, Jun 12, 2014 at 12:07 PM, Chris Angelico <ros...@gmail.com> wrote:
> ISTM what you want is not shell=True, but a separate function that
> follows the system policy for translating a command name into a
> path-to-binary. That's something that, AFAIK, doesn't currently exist
> in the Python 2 stdlib, but Python 3 has shutil.which(). If there's a
> PyPI backport of that for Py2, you should be able to use that to
> figure out the command name, and then avoid shell=False.

Huh. Next time, Chris, search the web before you post. Via a
StackOverflow post, learned about distutils.spawn.find_executable().

Python 2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils.spawn
>>> distutils.spawn.find_executable("python")
'C:\\Program Files\\LilyPond\\usr\\bin\\python.exe'

So that would be the way to go. Render the short-form into an
executable name, then skip the shell.

ChrisA
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to