[Tutor] Question about subprocess

eryksun eryksun at gmail.com
Sat Jan 11 10:30:55 CET 2014


On Fri, Jan 10, 2014 at 11:48 PM, daedae11 <daedae11 at 126.com> wrote:
> p = subprocess.Popen(['E:/EntTools/360EntSignHelper.exe',
> 'E:/build/temp/RemoteAssistSetup.exe'],
>                          stdout=subprocess.PIPE, shell=True).stdout

Is 360EntSignHelper supposed to run RemoteAssistSetup as a child
process? Or rather is it that from the command line you're piping the
output from the former into the latter? You'll need to provide more
information about what you mean by running the code "in command line".

Some general suggestions:

Remove shell=True. There's no reason to involve the shell here.
subprocess hides the window when you use shell=True, so maybe that's
why you're using it. But you can do that by setting the startupinfo
parameter to the following:

    si = subprocess.STARTUPINFO()
    si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    si.wShowWindow = subprocess.SW_HIDE

Also, as a matter of style, `p` is a bad name for stdout. It's not an
instance of [P]open representing a process.


More information about the Tutor mailing list