Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
611e6b5
Correct the description of ModuleSpec attributes
geryogam Oct 20, 2018
7113766
Update the description of the `submodule_search_locations` and `cache…
geryogam Oct 21, 2018
11ed136
Correct a typo
geryogam Oct 21, 2018
9a8d8e6
Fix and improve wording
geryogam Nov 26, 2018
859ff69
Document the read-only property for spec.parent
geryogam Nov 26, 2018
1f63f5b
Add information on the loader_state and has_location attributes
geryogam Dec 2, 2018
98fdbf7
Update importlib.rst
geryogam May 2, 2019
ac69aa1
Apply suggestions from code review
geryogam Jun 1, 2019
8bbdb64
Update importlib.rst
geryogam Jun 4, 2019
e126a5e
Update importlib.rst
geryogam Jun 4, 2019
7b7eb9d
Update importlib.rst
geryogam Jun 30, 2019
5290628
Update importlib.rst
geryogam Jun 30, 2019
89efbff
Update importlib.rst
geryogam Jun 30, 2019
8ba8ede
Apply suggestions from code review
geryogam Jul 13, 2019
2b7b6aa
Update import.rst
geryogam Jul 13, 2019
c71487c
Update import.rst
geryogam Jul 13, 2019
d7e66f6
Update import.rst
geryogam Jul 13, 2019
2123bb0
Update import.rst
geryogam Jul 13, 2019
3abaa63
Update importlib.rst
geryogam Jul 13, 2019
084915d
Update importlib.rst
geryogam Jul 13, 2019
88d2674
Update import.rst
geryogam Jul 13, 2019
37a5b86
Merge branch 'master' into patch-1
geryogam Aug 6, 2019
ee0625a
Apply suggestions from code review
geryogam Aug 9, 2019
cd0edda
Update importlib.rst
geryogam Aug 9, 2019
8957275
Remove changes to the language reference (to do in another PR)
geryogam Aug 9, 2019
9147e5c
Update importlib.rst
geryogam Aug 9, 2019
779a2f1
Update importlib.rst
geryogam Aug 10, 2019
ff0d5ae
Apply suggestions from code review
geryogam Aug 10, 2019
e651eb7
Update importlib.rst
geryogam Aug 10, 2019
9e8c67f
Apply suggestions from code review
geryogam Aug 10, 2019
d79b79a
Update Doc/library/importlib.rst
geryogam Sep 11, 2019
50cd998
Update importlib.rst
geryogam Sep 11, 2019
55e038d
Update importlib.rst
geryogam Sep 11, 2019
e8aa313
Update importlib.rst
geryogam Oct 23, 2020
51812a6
Update importlib.rst
geryogam Oct 24, 2020
3899dfa
Update importlib.rst
geryogam Oct 24, 2020
0a2790d
Merge branch 'master' into patch-1
geryogam Oct 24, 2020
ce8d9ac
Update Doc/library/importlib.rst
geryogam Jul 23, 2021
0cc0b11
Update Doc/library/importlib.rst
geryogam Jul 23, 2021
69d187d
Update importlib.rst
geryogam Jul 23, 2021
3461332
Update importlib.rst
geryogam Jul 29, 2021
19b0542
Apply suggestions from code review
geryogam Jul 29, 2021
5094cc5
Update importlib.rst
geryogam Jul 29, 2021
7bd4866
Update importlib.rst
geryogam Jul 29, 2021
fc40bb0
Update importlib.rst
geryogam Jul 29, 2021
60dc201
Update importlib.rst
geryogam Jul 29, 2021
fcea8dd
Update Doc/library/importlib.rst
brettcannon Nov 16, 2021
2bb2c14
Update Doc/library/importlib.rst
brettcannon Nov 16, 2021
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
Prev Previous commit
Next Next commit
Update importlib.rst
  • Loading branch information
geryogam authored Jul 13, 2019
commit 084915dcef4c64be12dd19bbf3f8b354acb2c536
90 changes: 31 additions & 59 deletions Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -423,25 +423,25 @@ ABC hierarchy::
The module's fully-qualified name.

- :attr:`__file__`
The location (usually filename) from which the module was imported.
The location from which the module was loaded (usually the path).
It is not set on all modules (e.g. built-in modules).
Comment thread
geryogam marked this conversation as resolved.

- :attr:`__cached__`
The path to where a compiled version of the module is stored.
The path to a compiled version of the code.
It is not set when the attribute would be inappropriate.

- :attr:`__path__`
The (possibly empty) iterable specifying the submodule search path
within a package.
The (possibly empty) iterable specifying the submodule search paths
Comment thread
geryogam marked this conversation as resolved.
Outdated
within the package.
It is not set on non-package modules.

- :attr:`__package__`
The fully-qualified name of the package the module is in (or the
empty string for top-level modules). For packages, it is the same
as ``__name__``.
The fully-qualified name of the package under which the module was
loaded as a submodule (or the empty string for top-level modules).
Comment thread
geryogam marked this conversation as resolved.
Outdated
For packages, it is the same as :attr:`__name__`.

- :attr:`__loader__`
The loader used when the module was imported.
The loader that was used when loading the module.
Comment thread
geryogam marked this conversation as resolved.
Outdated

When :meth:`exec_module` is available then backwards-compatible
functionality is provided.
Expand Down Expand Up @@ -1286,52 +1286,43 @@ find and load modules.
``module.__spec__.origin == module.__file__``. Note however that while
Comment thread
geryogam marked this conversation as resolved.
Outdated
Comment thread
geryogam marked this conversation as resolved.
Outdated
Comment thread
geryogam marked this conversation as resolved.
Outdated
the *values* are usually equivalent, they can differ since there is no
synchronization between the two objects. For example, it is possible
to update the module's ``__file__`` at runtime and this will not be
automatically reflected in the module's ``__spec__.origin``, and vice
versa.
to update the module's :attr:`__file__` at runtime and this will not be
automatically reflected in the module's :attr:`__spec__.origin`, and
vice versa.

.. versionadded:: 3.4

.. attribute:: name

(:attr:`__name__`)

The module's fully-qualified name.
It is not set for non-package modules run from the file system and
non-package modules run from standard input.
The module's fully-qualified name. Finders should always set this. A
Comment thread
geryogam marked this conversation as resolved.
Outdated
``None`` value has special meaning.
Comment thread
geryogam marked this conversation as resolved.
Outdated

.. attribute:: loader

(:attr:`__loader__`)

The loader to use when importing the module.
It is not set for non-package modules run from the file system and
non-package modules run from standard input.
The loader that should be used when loading the module. Finders should
Comment thread
geryogam marked this conversation as resolved.
Outdated
always set this. A ``None`` value is reserved for namespace packages.

.. attribute:: origin

(:attr:`__file__`)

The place from which the module's data was imported. Its value and meaning
is up to the finder.
It is the relative path for packages run from the file system and the
absolute path for imported modules and modules run from the module
namespace.
It is ``None`` for imported namespace packages, ``'built-in'`` for imported
built-in modules and ``'frozen'`` for imported frozen modules.
It is not set for non-package modules run from the file system and
non-package modules run from standard input.
The location from which the module should be loaded (e.g. ``'builtin'``
Comment thread
geryogam marked this conversation as resolved.
Outdated
for built-in modules and the path for modules loaded from source).
Comment thread
geryogam marked this conversation as resolved.
Outdated
Finders should normally set this attribute, but it may be ``None`` (the
default) which indicates it is unspecified (like for namespace packages).

.. attribute:: submodule_search_locations

(:attr:`__path__`)

The (possibly empty) iterable of all locations to search (i.e. the search
path) when looking for the package's submodules. Order is significant.
It is ``None`` for packages run from the file system, imported non-package
modules and modules run from the module namespace.
It is not set for non-package modules run from the file system and
non-package modules run from standard input.
The (possibly empty) iterable specifying the submodule search paths
Comment thread
geryogam marked this conversation as resolved.
Outdated
within the package (or ``None`` if not a package). Finders must set
this on a package, even if just to an empty list. For namespace
packages (where :attr:`origin` is ``None``) this is set automatically.

.. attribute:: loader_state

Expand All @@ -1342,41 +1333,22 @@ find and load modules.

(:attr:`__cached__`)

The location of the module's cached data. Some loaders support optimization
through caching the bytecode of the module. ``cached`` is how the finder
tells the loader where to look for that cached bytecode, or where to store
it.
It is the relative path for packages run from the file system and the
absolute path for imported modules and modules run from the module
namespace.
It is ``None`` for imported namespace packages, imported built-in modules
and imported frozen modules.
It is not set for non-package modules run from the file system and
non-package modules run from standard input.
The path to where a compiled version of the code should be stored (or
Comment thread
geryogam marked this conversation as resolved.
Outdated
``None``).

.. attribute:: parent

(:attr:`__package__`)

The module's ``__spec.__name`` attribute for imported packages and packages
run from the module namespace, the parent package's ``__spec__.name``
attribute for imported non-package submodules and non-paclage submodules run
from the module namespace and ``''`` for packages run from the file system,
imported non-package top-level modules and non-package top-level modules run
from the module namespace.
It is not set for non-package modules run from the file system and
non-package modules run from standard input.
It is a read-only attribute.
(Read-only) The fully-qualified name of the package under which the
module should be loaded as a submodule (or the empty string for top-level
modules). For packages, it is the same as :attr:`__name__`.
Comment thread
geryogam marked this conversation as resolved.
Outdated

.. attribute:: has_location

The Boolean indicating whether or not the module's ``origin`` attribute
refers to a locatable module.
It is ``True`` for packages run from the file system, imported modules and
modules run from the module namespace and ``False`` for imported namespace
packages, imported built-in modules and imported frozen modules.
It is not set for non-package modules run from the file system and
non-package modules run from standard input.
True if the spec's :attr:`origin` refers to a loadable location. False
otherwise. This value impacts how :attr:`origin` is interpreted and how
the module's :attr:`__file__`` is populated.

:mod:`importlib.util` -- Utility code for importers
---------------------------------------------------
Expand Down