Sarge is one way to appropriately wrap Process Control (with shell-like piping of stdin and stdout between multiple processes).
os.system just calls C system(), AFAIU subprocess.call calls subprocess.Popen, which does far more than just wrapping C system(); though the return value is also the process returncode. https://sarge.readthedocs.io/en/latest/ https://docs.python.org/3/library/os.html#os.system https://github.com/python/cpython/blob/master/Modules/posixmodule.c https://docs.python.org/3/library/subprocess.html#subprocess.Popen.returncode https://docs.python.org/3/library/subprocess.html#subprocess.call https://docs.python.org/3/library/subprocess.html#subprocess.check_call https://en.wikipedia.org/wiki/System_call https://en.wikipedia.org/wiki/Exec_(system_call) ... "ENH: Add call, check_call, check_output, CalledProcessError, expect_returncode" https://bitbucket.org/vinay.sajip/sarge/pull-requests/1/enh-add-call-check_call-check_output/diff On Wednesday, October 24, 2018, Steve Dower <steve.do...@python.org> wrote: > On 24Oct2018 0934, Calvin Spealman wrote: > >> In the spirit of "There should be one-- and preferably only one --obvious >> way to do it." this makes perfect sense. >> > > To do what? There is one obvious way to run a system command, and one > obvious way to manage subprocesses. There are also many non-obvious ways to > run system commands, and many non-obvious ways to manage subprocesses. > > The distinction between "your own machine and other peoples machines" is >> not always clear, nor planned for, nor understood by developers to be an >> important distinction to make up-front. So the encouragement should be >> clear. >> > > Agreed. One good heuristic is whether you're putting the system command in > a function or not, since functions are explicitly designing for reuse while > just using it in a script is not. > > Simply put, there is no valid use case for os.system over subprocess by >> remaining it must be considered redundant. >> > > You have not shown this. Posting quotes followed by an unrelated > conclusion isn't a very compelling form of argument :) > > Cheers, > Steve > _______________________________________________ > 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/wes. > turner%40gmail.com >
_______________________________________________ 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