[issue39857] subprocess.run: add an extra_env kwarg to complement existing env kwarg

2020-03-10 Thread Gregory P. Smith
Gregory P. Smith added the comment: I think those dict unpacking and merging options are sufficient that adding an extra_env= parameter would merely complicate the already over complex API. Thanks for the suggestions folks! -- resolution: -> rejected stage: -> resolved status:

[issue39857] subprocess.run: add an extra_env kwarg to complement existing env kwarg

2020-03-10 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +gregory.p.smith ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue39857] subprocess.run: add an extra_env kwarg to complement existing env kwarg

2020-03-10 Thread Caleb Hattingh
Caleb Hattingh added the comment: The dict unpacking generalizations that I posted were added in Python 3.5, which is pretty old by now. (But, true, is in Python 3 and not Python 2). This is the PEP: https://www.python.org/dev/peps/pep-0448/ The new syntax that Brandt posted will indeed

[issue39857] subprocess.run: add an extra_env kwarg to complement existing env kwarg

2020-03-10 Thread Mike Frysinger
Mike Frysinger added the comment: personally i still like having the extra_env setting explicitly broken out, but i agree that those operators help ease the majority of the pain. i hadn't come across them before as they aren't in Python 2. i wouldn't be upset if people declined the FR

[issue39857] subprocess.run: add an extra_env kwarg to complement existing env kwarg

2020-03-07 Thread Brandt Bucher
Brandt Bucher added the comment: Ah, I didn't realize that os.environ and os.environ b aren't dict subclasses. I've added a ticket to update them with the new operators! -- ___ Python tracker

[issue39857] subprocess.run: add an extra_env kwarg to complement existing env kwarg

2020-03-07 Thread Brandt Bucher
Brandt Bucher added the comment: Caleb's answer, using PEP 584's merge operator: newenv = os.environ | {'FOO': ..., 'BAR': ...} subprocess.run(..., env=new_env, ...) -- nosy: +brandtbucher ___ Python tracker

[issue39857] subprocess.run: add an extra_env kwarg to complement existing env kwarg

2020-03-07 Thread Caleb Hattingh
Caleb Hattingh added the comment: dict syntax tools make it fairy easy to compose new dicts from old ones with overrides: subprocess.run(..., env={**os.environ, 'FOO': ..., 'BAR', ...}, ...) Would this be sufficient to avoid the copy/pasting boilerplate? -- nosy: +cjrh

[issue39857] subprocess.run: add an extra_env kwarg to complement existing env kwarg

2020-03-04 Thread Mike Frysinger
New submission from Mike Frysinger : 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