Fix Python – What is the difference between subprocess.popen and


Asked By – jath03

I’m new to the subprocess module and the documentation leaves me wondering what the difference is between subprocess.popen and Is there a difference in what the command does? Is one just newer? Which is better to use?

Now we will see solution for issue: What is the difference between subprocess.popen and

Answer was added in Python 3.5 as a simplification over subprocess.Popen when you just want to execute a command and wait until it finishes, but you don’t want to do anything else in the mean time. For other cases, you still need to use subprocess.Popen.

The main difference is that executes a command and waits for it to finish, while with subprocess.Popen you can continue doing your stuff while the process finishes and then just repeatedly call Popen.communicate() yourself to pass and receive data to your process. Secondly, returns subprocess.CompletedProcess. just wraps Popen and Popen.communicate() so you don’t need to make a loop to pass/receive data or wait for the process to finish.

Check the official documentation for info on which params pass to Popen and communicate().

This question is answered By – Daniel

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0