Calling Other Programs with subprocess

You can use the subprocess standard library module to invoke other command line programs available on your system and process their results in Python. You might find the subprocess useful if, for example, you want to call a program like git from inside Python to learn about the current state of your version controlled project. Indeed, some examples in this section will combine subprocess and git to do just that.

Note, if you don’t have git installed on your machine or are not currently in a directory with a git repository, some of the following examples may not successfully execute on your computer. You can download git if you like,[49] but it’s also OK to just follow along with the examples here so you ...

Get Intuitive Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.