Skip to content
Prev Previous commit
Address Victor's nits
  • Loading branch information
ambv committed Oct 14, 2023
commit 2e1d1805b5302ad3529d43b08271ae5de8649be2
20 changes: 13 additions & 7 deletions Doc/using/cmdline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,11 @@ Miscellaneous options
container system. See also :envvar:`PYTHON_CPU_COUNT`.
If *n* is ``default``, nothing is overridden.
* :samp:`-X presite={package.module}` specifies a module that should be
imported before ``site.py`` is executed and before the :mod:`__main__`
module exists. Therefore, the imported module isn't :mod:`__main__`.
Python needs to be :ref:`built in debug mode <debug-build>` for this
option to exist. See also :envvar:`PYTHON_PRESITE`.
imported before the :mod:`site` module is executed and before the
:mod:`__main__` module exists. Therefore, the imported module isn't
:mod:`__main__`. This can be used to execute code early during Python
initialization. Python needs to be :ref:`built in debug mode <debug-build>`
for this option to exist. See also :envvar:`PYTHON_PRESITE`.

It also allows passing arbitrary values and retrieving them through the
:data:`sys._xoptions` dictionary.
Expand Down Expand Up @@ -1113,9 +1114,14 @@ Debug-mode variables
.. envvar:: PYTHON_PRESITE
Comment thread
ambv marked this conversation as resolved.

If this variable is set to a module, that module will be imported
early in the interpreter lifecycle, before ``site.py`` is executed,
and before the :mod:`__main__` module is created. Therefore, the
imported module is not treated as :mod:`__main__`.
early in the interpreter lifecycle, before the :mod:`site` module is
executed, and before the :mod:`__main__` module is created.
Therefore, the imported module is not treated as :mod:`__main__`.

This can be used to execute code early during Python initialization.

To import a submodule, use ``package.module`` as the value, like in
an import statement.

See also the :option:`-X presite <-X>` command-line option,
which takes precedence over this variable.
Expand Down