Using the Python subprocess Module - Real Python
Briefly

The article introduces Python's subprocess module, which facilitates running shell commands and managing external processes from Python scripts. Key functionalities include executing commands with subprocess.run(), and understanding the distinctions between subprocess.call(), subprocess.run(), and subprocess.Popen(). The subprocess module also aids in error handling and process communication. Additionally, it differentiates between multiprocessing, used for parallel execution within Python, and subprocess for external process management. Chaining commands using pipes or sequential execution is an essential feature of this module, enhancing its versatility in Python projects.
The Python subprocess module is used to run shell commands and manage external processes. You run a shell command using subprocess by calling subprocess.run() with the command as a list of arguments.
subprocess.call(), subprocess.run(), and subprocess.Popen() differ in how they execute commands and handle process output and return codes.
multiprocessing is for parallel execution within Python, while subprocess manages external processes.
To execute multiple commands in sequence using subprocess, you can chain them by using pipes or running them consecutively.
Read at Realpython
[
|
]