Message363413
a common idiom i run into is wanting to add/set one or two env vars when running a command via subprocess. the only thing the API allows currently is inherting the current environment, or specifying the complete environment. this means a lot of copying & pasting of the pattern:
env = os.environ.copy()
env['FOO'] = ...
env['BAR'] = ...
subprocess.run(..., env=env, ...)
it would nice if we could simply express this incremental behavior:
subprocess.run(..., extra_env={'FOO': ..., 'BAR': ...}, ...)
then the subprocess API would take care of copying & merging.
if extra_env:
assert env is None
env = os.environ.copy()
env.update(extra_env)
this is akin to subprocess.run's capture_output shortcut.
it's unclear to me whether this would be in both subprocess.Popen & subprocess.run, or only subprocess.run. it seems like subprocess.Popen elides convenience APIs. |
|
Date |
User |
Action |
Args |
2020-03-05 02:10:18 | vapier | set | recipients:
+ vapier |
2020-03-05 02:10:18 | vapier | set | messageid: <1583374218.17.0.443069658502.issue39857@roundup.psfhosted.org> |
2020-03-05 02:10:18 | vapier | link | issue39857 messages |
2020-03-05 02:10:17 | vapier | create | |
|