[Python-ideas] String interpolation: environment variables, command substitution

Paul Moore p.f.moore at gmail.com
Wed Aug 26 21:54:42 CEST 2015


On 26 August 2015 at 20:16, Mike Miller <python-ideas at mgmiller.net> wrote:
> The use case is for shell-script replacements, which can be but are often
> not typically cross-platform.   Let's try different examples:
>
>     >>> x'version: {$(/usr/bin/xdpyinfo -version)}'  # capture
>     'version: xdpyinfo 1.3.1'
>
>     >>> x'display: {$DISPLAY}'                       # env
>     'display: :0.0'

This is not an important enough use case to warrant language support, IMO.

If you want something like this, there are a lot of tools already
available on PyPI:

https://pypi.python.org/pypi/invoke/0.10.1 if you want to run sets of
command lines, grouped together as "tasks"
https://pypi.python.org/pypi/sarge/0.1.4 if you're looking for a
shell-like syntax (with cross-platform support for constructs like &&,
|| etc)
http://plumbum.readthedocs.org/en/latest/ if you want access to shell
commands from within Python code

and probably a host of others.

Honestly, this is starting to feel like Perl. Sorry, but I don't like
this proposal at all.

Paul


More information about the Python-ideas mailing list