[Python-ideas] Add output() helper function to subprocess module
Serhiy Storchaka
storchaka at gmail.com
Thu Apr 4 06:22:05 EDT 2019
04.04.19 11:59, Greg Ewing пише:
> Nathaniel Smith wrote:
>> On Thu, Apr 4, 2019 at 12:48 AM Greg Ewing
>> <greg.ewing at canterbury.ac.nz> wrote:
>>> output(args) --> (status, output)
>>
>> Isn't this already available as: run(args, stdout=PIPE)?
>
> Yes, but you need to do more than that to get the output
> as a string. This is the relevant part of the implementation
> of check_output():
>
> process = Popen(stdout=PIPE, *popenargs, **kwargs)
> output, unused_err = process.communicate()
> retcode = process.poll()
>
check_output() is currently implemented (besides arguments checks and
legacy support) as just
run(..., stdout=PIPE, check=True).stdout
For getting unchecked output you need just to omit check=True.
run(..., stdout=PIPE).stdout
I think that after adding run() there is no need in output().
More information about the Python-ideas
mailing list