subprocess.run(args, capture_output=True, check=True, text=True, encoding="utf8").stdout ? On Thu, 26 Aug 2021, 13:55 Evan Greenup via Python-ideas, < python-ideas@python.org> wrote:
Currently, when what to execute external command, either os.system() or subprocess functions should be invoked.
However, it is not so convenient, it would be nice to use "``" symbol to brace the shell command inside.
like:
stdout_result_str = `cat file.txt | sort | grep hello`
Its is enhanced feature which combine both subprocess and os.system
Because, subprocess can return output of file, but does not support pipe in command.
While os.system can apply pipe in command but doesn't support return stdout result.
This can be very convenient to make python available for some build script which ruby now do well like homebrew ...
simply
`echo hello | wc -l` while only execute command and the result will just like other unassigned expression, the result will be finally discarded.
There won't be big difficulties to implement. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/5KKHG6... Code of Conduct: http://python.org/psf/codeofconduct/