I assume you are stuck on understanding:
"Nevertheless, quit should not be used in production code. This is
because it only works if the site module is loaded. Instead, this
function should only be used in the interpreter."
Basically, what that is saying is that quit
is a part of a module loaded in the python interpreter. That module's name, is site.
Firstly, the python interpreter is what you use to run python scripts or environments. It interprets python commands. For example, if you write a = 1
in a script or python environment, the interpreter takes that command and executes it without compiling it. (If it was a language like c you would need to compile the script before you run it).
Secondly, a module is a pre-written file that can define functions, classes and variables. When you write import numpy
into python, you are importing the module, numpy. Therefore when they say "this only works if the site module is loaded", that means that import site
must be executed.
When you start a python interpreter (by typing python
into your command shell), it automatically imports site
, which has sys
, venv
and main
etc. which are all required to run an active interpreter session.