According to Difference between exit() and sys.exit() in Python, the preferred way to exit from a Python application is to use sys.exit()
. Python's documentation states that exit()
should only be used to exit from the interactive shell.
The
site
module (which is imported automatically during startup, except if the-S
command-line option is given) adds several constants to the built-in namespace. They are useful for the interactive interpreter shell and should not be used in programs.
While the documentation warns against using constants from the site
module, it doesn't explain why we shouldn't use them.
Why shouldn't exit()
be used in Python applications?