Skip to content

Commit 210dc3b

Browse files
[3.7] bpo-33095: Add reference to isolated mode in -m and script option (GH-7764) (GH-16181)
Attempt to make isolated mode easier to discover via additional inline documentation. Co-Authored-By: Julien Palard <[email protected]>. (cherry picked from commit bdd6945) Co-authored-by: Xtreak <[email protected]>
1 parent e857fe6 commit 210dc3b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Doc/using/cmdline.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ source.
100100
first element will be set to ``"-m"``). As with the :option:`-c` option,
101101
the current directory will be added to the start of :data:`sys.path`.
102102

103+
:option:`-I` option can be used to run the script in isolated mode where
104+
:data:`sys.path` contains neither the current directory nor the user's
105+
site-packages directory. All :envvar:`PYTHON*` environment variables are
106+
ignored, too.
107+
103108
Many standard library modules contain code that is invoked on their execution
104109
as a script. An example is the :mod:`timeit` module::
105110

@@ -119,6 +124,7 @@ source.
119124
.. versionchanged:: 3.4
120125
namespace packages are also supported
121126

127+
.. _cmdarg-dash:
122128

123129
.. describe:: -
124130

@@ -130,6 +136,8 @@ source.
130136
:data:`sys.path`.
131137

132138

139+
.. _cmdarg-script:
140+
133141
.. describe:: <script>
134142

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

159+
:option:`-I` option can be used to run the script in isolated mode where
160+
:data:`sys.path` contains neither the script's directory nor the user's
161+
site-packages directory. All :envvar:`PYTHON*` environment variables are
162+
ignored, too.
163+
151164
.. seealso::
152165
:func:`runpy.run_path`
153166
Equivalent functionality directly available to Python code

0 commit comments

Comments
 (0)