Python provides a specific “hook” to let each site customize some aspects of Python’s behavior at the start of each run. Customization by each single user is not enabled by default, but Python specifies how programs that want to run user-provided code at startup can explicitly request such customization.
Python loads standard module
site just before the main script. If Python is run with option -S, Python does not load
site. -S allows faster startup but saddles the main script with initialization chores.
site’s tasks are:
sys.path in standard form (absolute paths, no duplicates).
Interpreting each .pth file found in the Python home directory, adding entries to
sys.path, and/or importing modules, as each .pth file indicates.
Adding built-ins used to display information in interactive sessions (
Setting the default Unicode encoding to
site’s source code includes two blocks, each guarded by
if 0:, one to set the default encoding to be locale-dependent, and the other to completely disable any default encoding between Unicode and plain strings. You may optionally edit site.py to select either block.
Trying to import
import sitecustomize raise an
site catches and ignores it).
sitecustomize is the module that each site’s installation can optionally use for further site-specific customization beyond
site’s tasks. It is generally ...