Introducing system modules in Python
Python provides in its standard library some system modules, of which we will highlight three:
- The
os
module - The
sys
module - The
subprocess
module
These modules allow us to access functionalities such as knowing the Python environment we are executing, managing directories, finding information about the interpreter, and the possibility to execute commands in the operating system.
In this first section of the chapter, we’ll review the main modules you can find for working with the Python interpreter, the operating system, and for executing commands with the subprocess
module.
The system (sys) module
The sys
module allows us to interact with the interpreter and it contains most of the information related to the execution in progress, updated by the interpreter, as well as a series of functions and low-level objects.
Let’s take a look at an example. sys.argv
contains the list of parameters for executing...