Skip to content

[3.8] bpo-33095: Add reference to isolated mode in -m and script option (GH-7764) #16180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Doc/using/cmdline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ source.
first element will be set to ``"-m"``). As with the :option:`-c` option,
the current directory will be added to the start of :data:`sys.path`.

:option:`-I` option can be used to run the script in isolated mode where
:data:`sys.path` contains neither the current directory nor the user's
site-packages directory. All :envvar:`PYTHON*` environment variables are
ignored, too.

Many standard library modules contain code that is invoked on their execution
as a script. An example is the :mod:`timeit` module::

Expand All @@ -121,6 +126,7 @@ source.
.. versionchanged:: 3.4
namespace packages are also supported

.. _cmdarg-dash:

.. describe:: -

Expand All @@ -133,6 +139,8 @@ source.

.. audit-event:: cpython.run_stdin "" ""

.. _cmdarg-script:

.. describe:: <script>

Execute the Python code contained in *script*, which must be a filesystem
Expand All @@ -151,6 +159,11 @@ source.
added to the start of :data:`sys.path` and the ``__main__.py`` file in
that location is executed as the :mod:`__main__` module.

:option:`-I` option can be used to run the script in isolated mode where
:data:`sys.path` contains neither the script's directory nor the user's
site-packages directory. All :envvar:`PYTHON*` environment variables are
ignored, too.

.. audit-event:: cpython.run_file filename

.. seealso::
Expand Down