Skip to content

Commit 2b9828e

Browse files
geryogamGlyphack
authored andcommitted
Docs: minor amendments to runpy.rst (python#18416)
- Add missing single quote in inline code - Align parameter formatting with style guide recommendations - Fix punctuation around parenthesised sentence
1 parent 531625c commit 2b9828e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

Doc/library/runpy.rst

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The :mod:`runpy` module provides two functions:
3232
.. index::
3333
pair: module; __main__
3434

35-
Execute the code of the specified module and return the resulting module
35+
Execute the code of the specified module and return the resulting module's
3636
globals dictionary. The module's code is first located using the standard
3737
import mechanism (refer to :pep:`302` for details) and then executed in a
3838
fresh module namespace.
@@ -44,24 +44,24 @@ The :mod:`runpy` module provides two functions:
4444
returned.
4545

4646
The optional dictionary argument *init_globals* may be used to pre-populate
47-
the module's globals dictionary before the code is executed. The supplied
48-
dictionary will not be modified. If any of the special global variables
49-
below are defined in the supplied dictionary, those definitions are
47+
the module's globals dictionary before the code is executed.
48+
*init_globals* will not be modified. If any of the special global variables
49+
below are defined in *init_globals*, those definitions are
5050
overridden by :func:`run_module`.
5151

5252
The special global variables ``__name__``, ``__spec__``, ``__file__``,
5353
``__cached__``, ``__loader__`` and ``__package__`` are set in the globals
54-
dictionary before the module code is executed (Note that this is a
54+
dictionary before the module code is executed. (Note that this is a
5555
minimal set of variables - other variables may be set implicitly as an
56-
interpreter implementation detail).
56+
interpreter implementation detail.)
5757

5858
``__name__`` is set to *run_name* if this optional argument is not
5959
:const:`None`, to ``mod_name + '.__main__'`` if the named module is a
6060
package and to the *mod_name* argument otherwise.
6161

6262
``__spec__`` will be set appropriately for the *actually* imported
6363
module (that is, ``__spec__.name`` will always be *mod_name* or
64-
``mod_name + '.__main__``, never *run_name*).
64+
``mod_name + '.__main__'``, never *run_name*).
6565

6666
``__file__``, ``__cached__``, ``__loader__`` and ``__package__`` are
6767
:ref:`set as normal <import-mod-attrs>` based on the module spec.
@@ -104,11 +104,11 @@ The :mod:`runpy` module provides two functions:
104104
pair: module; __main__
105105

106106
Execute the code at the named filesystem location and return the resulting
107-
module globals dictionary. As with a script name supplied to the CPython
108-
command line, the supplied path may refer to a Python source file, a
107+
module's globals dictionary. As with a script name supplied to the CPython
108+
command line, *file_path* may refer to a Python source file, a
109109
compiled bytecode file or a valid :data:`sys.path` entry containing a
110110
:mod:`__main__` module
111-
(e.g. a zipfile containing a top-level ``__main__.py`` file).
111+
(e.g. a zipfile containing a top-level :file:`__main__.py` file).
112112

113113
For a simple script, the specified code is simply executed in a fresh
114114
module namespace. For a valid :data:`sys.path` entry (typically a zipfile or
@@ -119,34 +119,34 @@ The :mod:`runpy` module provides two functions:
119119
there is no such module at the specified location.
120120

121121
The optional dictionary argument *init_globals* may be used to pre-populate
122-
the module's globals dictionary before the code is executed. The supplied
123-
dictionary will not be modified. If any of the special global variables
124-
below are defined in the supplied dictionary, those definitions are
122+
the module's globals dictionary before the code is executed.
123+
*init_globals* will not be modified. If any of the special global variables
124+
below are defined in *init_globals*, those definitions are
125125
overridden by :func:`run_path`.
126126

127127
The special global variables ``__name__``, ``__spec__``, ``__file__``,
128128
``__cached__``, ``__loader__`` and ``__package__`` are set in the globals
129-
dictionary before the module code is executed (Note that this is a
129+
dictionary before the module code is executed. (Note that this is a
130130
minimal set of variables - other variables may be set implicitly as an
131-
interpreter implementation detail).
131+
interpreter implementation detail.)
132132

133133
``__name__`` is set to *run_name* if this optional argument is not
134134
:const:`None` and to ``'<run_path>'`` otherwise.
135135

136-
If the supplied path directly references a script file (whether as source
137-
or as precompiled byte code), then ``__file__`` will be set to the
138-
supplied path, and ``__spec__``, ``__cached__``, ``__loader__`` and
136+
If *file_path* directly references a script file (whether as source
137+
or as precompiled byte code), then ``__file__`` will be set to
138+
*file_path*, and ``__spec__``, ``__cached__``, ``__loader__`` and
139139
``__package__`` will all be set to :const:`None`.
140140

141-
If the supplied path is a reference to a valid :data:`sys.path` entry, then
141+
If *file_path* is a reference to a valid :data:`sys.path` entry, then
142142
``__spec__`` will be set appropriately for the imported :mod:`__main__`
143143
module (that is, ``__spec__.name`` will always be ``__main__``).
144144
``__file__``, ``__cached__``, ``__loader__`` and ``__package__`` will be
145145
:ref:`set as normal <import-mod-attrs>` based on the module spec.
146146

147147
A number of alterations are also made to the :mod:`sys` module. Firstly,
148148
:data:`sys.path` may be altered as described above. ``sys.argv[0]`` is updated
149-
with the value of ``path_name`` and ``sys.modules[__name__]`` is updated
149+
with the value of *file_path* and ``sys.modules[__name__]`` is updated
150150
with a temporary module object for the module being executed. All
151151
modifications to items in :mod:`sys` are reverted before the function
152152
returns.

0 commit comments

Comments
 (0)