![](https://secure.gravatar.com/avatar/512cfbaf98d63ca4acd57b2df792aec6.jpg?s=120&d=mm&r=g)
On Thu, Apr 04, 2019 at 07:44:29PM +1100, Chris Angelico <rosuav@gmail.com> wrote:
On Thu, Apr 4, 2019 at 7:12 PM Nathaniel Smith <njs@pobox.com> wrote:
On Thu, Apr 4, 2019 at 12:48 AM Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
The check_output() function of the subprocess module raises an exception if the process returns a non-zero exit status. This is inconvenient for commands such as grep that use the return status to indicate something other than success or failure.
The check_call() function has a companion call(), but here is currently no non-checking companion for check_call(). How about adding one with a signature such as
output(args) --> (status, output)
Isn't this already available as: run(args, stdout=PIPE)? Is the object to the extra typing, or...?
Or discoverability. If you want to run a subprocess and catch its output, you'll naturally reach for check_output, and it feels clunkier to have to use run() instead.
+1 on adding a nice simple function, although I'm not 100% sold on the name "output".
get_output ?
ChrisA
Oleg. -- Oleg Broytman https://phdru.name/ phd@phdru.name Programmers don't die, they just GOSUB without RETURN.