If you look at the subprocess section in Python docs , you'll notice that there is an example of how to replace os.system() with subprocess.Popen() :
sts = os.system("mycmd" + " myarg")
... does the same as ...
sts = Popen("mycmd" + " myarg", shell=True).wait()
The "improved" code looks more complex, but better, because as soon as you know subprocess.Popen() , you don't need anything else. subprocess.Popen() replaces several other tools ( os.system() is just one of them) that were scattered across three other Python modules.
If this helps, think of subprocess.Popen() as a very flexible os.system() .
Jacob Marble Jan 27 2018-11-11T00: 00Z
source share