On Wed, Sep 4, 2013 at 7:11 AM, Oscar Benjamin <oscar.j.benja...@gmail.com> wrote: > On 4 September 2013 11:42, eryksun <eryk...@gmail.com> wrote: >>>> si = subprocess.STARTUPINFO() >>>> si.dwFlags |= subprocess.STARTF_USESHOWWINDOW >>>> si.wShowWindow = subprocess.SW_HIDE >>> >>> Do these statements modify module-level state? Or do you need to pass >>> startupinfo=si when calling Popen? >> >> It's a documented option for instances of Popen, to configure a few >> fields in the STARTUPINFO struct that gets passed to CreateProcess. > > It's not clear from the docs (or your explanation) whether the lines > above modify a global STARTUPINFO struct that gives default behaviour > to subprocesses or if it is just the way to initialise one that can be > passed to Popen or the convenience APIs. I guess the latter in which > case it's probably better to be explicit and say: > > si = subprocess.STARTUPINFO() > si.dwFlags |= subprocess.STARTF_USESHOWWINDOW > si.wShowWindow = subprocess.SW_HIDE > subprocess.check_call(cmdargs, startupinfo=si)
When I said, "[s]et startupinfo=si, where si is defined", I assumed familiarity with the Popen constructor: subprocess.Popen( args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0) ... If given, startupinfo will be a STARTUPINFO object, which is passed to the underlying CreateProcess function. creationflags, if given, can be CREATE_NEW_CONSOLE or CREATE_NEW_PROCESS_GROUP. http://docs.python.org/2/library/subprocess#popen-constructor _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor