The subprocess Module: Wrapping Programs With Python
If you’ve ever wanted to simplify your command-line scripting or use Python alongside command-line applications—or any applications for that matter—then the Python subprocess
module can help. From running shell commands and command-line applications to launching GUI applications, the Python subprocess
module can help.
By the end of this tutorial, you’ll be able to:
- Understand how the Python
subprocess
module interacts with the operating system - Issue shell commands like
ls
ordir
- Feed input into a process and use its output.
- Handle errors when using
subprocess
- Understand the use cases for
subprocess
by considering practical examples
In this tutorial, you’ll get a high-level mental model for understanding processes, subprocesses, and Python before getting stuck into the subprocess
module