Commit 077ffbb2 authored by Barry Warsaw's avatar Barry Warsaw

Finally, a coherent set of terminology for all the lil' beasties involved.

parent c215e7e7
......@@ -315,6 +315,13 @@ Glossary
role in places where a constant hash value is needed, for example as a key
in a dictionary.
import path
A list of locations (or :term:`path entries <path entry>`) that are
searched by the :term:`path importer` for modules to import. During
import, this list of locations usually comes from :data:`sys.path`, but
for subpackages it may also come from the parent package's ``__path__``
attribute.
importing
The process by which Python code in one module is made available to
Python code in another module.
......@@ -446,8 +453,8 @@ Glossary
meta path finder
A finder returned by a search of :data:`sys.meta_path`. Meta path
finders are related to, but different from :term:`sys path finders <sys
path finder>`.
finders are related to, but different from :term:`path entry finders
<path entry finder>`.
metaclass
The class of a class. Class definitions create a class name, a class
......@@ -541,9 +548,23 @@ Glossary
subpackages. Technically, a package is a Python module with an
``__path__`` attribute.
path entry
A single location on the :term:`import path` which the :term:`path
importer` consults to find modules for importing.
path entry finder
A :term:`finder` returned by a callable on :data:`sys.path_hooks`
(i.e. a :term:`path entry hook`) which knows how to locate modules given
a :term:`path entry`.
path entry hook
A callable on the :data:`sys.path_hook` list which returns a :term:`path
entry finder` if it knows how to find modules on a specific :term:`path
entry`.
path importer
A built-in :term:`finder` / :term:`loader` that knows how to find and
load modules from the file system.
One of the default :term:`meta path finders <meta path finder>` which
searches an :term:`import path` for modules.
portion
A set of files in a single directory (possibly stored in a zip file)
......@@ -671,11 +692,6 @@ Glossary
:meth:`~collections.somenamedtuple._asdict`. Examples of struct sequences
include :data:`sys.float_info` and the return value of :func:`os.stat`.
sys path finder
A finder returned by a search of :data:`sys.path` by the :term:`path
importer`. Sys path finders are related to, but different from
:term:`meta path finders <meta path finder>`.
triple-quoted string
A string which is bound by three instances of either a quotation mark
(") or an apostrophe ('). While they don't provide any functionality
......
......@@ -652,15 +652,16 @@ Modules
object: module
Modules are a basic organizational unit of Python code, and are created by
the :ref:`importmachinery` as invoked either by the :keyword:`import`
statement (see section :ref:`import`) or by calling the built in
:func:`__import__` function. A module object has a namespace implemented
by a dictionary object (this is the dictionary referenced by the
``__globals__`` attribute of functions defined in the module). Attribute
references are translated to lookups in this dictionary, e.g., ``m.x`` is
equivalent to ``m.__dict__["x"]``. A module object does not contain the
code object used to initialize the module (since it isn't needed once the
initialization is done).
the :ref:`import system <importsystem>` as invoked either by the
:keyword:`import` statement (see :keyword:`import`), or by calling
functions such as :func:`importlib.import_module` and built-in
:func:`__import__`. A module object has a namespace implemented by a
dictionary object (this is the dictionary referenced by the ``__globals__``
attribute of functions defined in the module). Attribute references are
translated to lookups in this dictionary, e.g., ``m.x`` is equivalent to
``m.__dict__["x"]``. A module object does not contain the code object used
to initialize the module (since it isn't needed once the initialization is
done).
Attribute assignment updates the module's namespace dictionary, e.g.,
``m.x = 1`` is equivalent to ``m.__dict__["x"] = 1``.
......
......@@ -24,7 +24,7 @@ interfaces available to C/C++ programmers in detail.
lexical_analysis.rst
datamodel.rst
executionmodel.rst
import_machinery.rst
import.rst
expressions.rst
simple_stmts.rst
compound_stmts.rst
......
......@@ -662,14 +662,17 @@ The :keyword:`import` statement
Import statements are executed in two steps: (1) find a module, loading and
initializing it if necessary; (2) define a name or names in the local
namespace (of the scope where the :keyword:`import` statement occurs). The
statement comes in two forms differing on whether it uses the :keyword:`from`
keyword. The first form (without :keyword:`from`) repeats these steps for each
identifier in the list. The form with :keyword:`from` performs step (1) once,
and then performs step (2) repeatedly.
namespace (of the scope where the :keyword:`import` statement occurs).
Step (1) may be performed recursively if the named module is a submodule or
subpackage of a parent package.
The :keyword:`import` statement comes in two forms differing on whether it
uses the :keyword:`from` keyword. The first form (without :keyword:`from`)
repeats these steps for each identifier in the list. The form with
:keyword:`from` performs step (1), and then performs step (2) repeatedly.
The details of step (1), finding and loading modules is described in greater
detail in the section on the :ref:`import machinery <importmachinery>`, which
detail in the section on the :ref:`import system <importsystem>`, which
also describes the various types of packages and modules that can be imported,
as well as all the hooks that can be used to customize Python's import.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment