The builtin module sys provides an access point to the Python environment. You find there command line arguments, the import path settings, the standard input, output and error stream and many more.
The sys.path variable contains the current directory, everything from the PYTHONPATH environment variable, and Pythons own folders.
import sys
print(sys.path)The variable sys.argv contains a list of command-line arguments.
The first one is usually the name of the called script.
print(sys.argv)When you call this program with any of:
python script.py python script.py hello world python script.py 1 2 3
You should see a difference.
The sys.exit() function ends execution of the Python interpreter immediately.
import sys
sys.exit().. seealso:: `Documentation of the sys module <https://docs.python.org/3/library/sys.html>`__