Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit debb98d

Browse files
committed
Document importlib.machinery.PathFinder.
1 parent 0d4785b commit debb98d

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

Doc/library/importlib.rst

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ implementation of the :keyword:`import` statement (and thus, by extension, the
1818
:func:`__import__` function) in Python source code. This provides an
1919
implementaiton of :keyword:`import` which is portable to any Python
2020
interpreter. This also provides a reference implementation which is easier to
21-
read than one in a programming language other than Python.
21+
comprehend than one in a programming language other than Python.
2222

2323
Two, the components to implement :keyword:`import` can be exposed in this
2424
package, making it easier for users to create their own custom objects (known
25-
generically as importers) to participate in the import process. Details on
26-
providing custom importers can be found in :pep:`302`.
25+
generically as an :term:`importer`) to participate in the import process.
26+
Details on providing custom importers can be found in :pep:`302`.
2727

2828
.. seealso::
2929

@@ -126,3 +126,28 @@ find and load modules.
126126

127127
Class method that allows this class to be a :term:`loader` for frozen
128128
modules.
129+
130+
131+
.. class:: PathFinder
132+
133+
:term:`Finder` for :data:`sys.path`.
134+
135+
This class does not perfectly mirror the semantics of :keyword:`import` in
136+
terms of :data:`sys.path`. No implicit path hooks are assumed for
137+
simplification of the class and its semantics.
138+
139+
Only class method are defined by this class to alleviate the need for
140+
instantiation.
141+
142+
.. classmethod:: find_module(fullname, path=None)
143+
144+
Class method that attempts to find a :term:`loader` for the module
145+
specified by *fullname* either on :data:`sys.path` or, if defined, on
146+
*path*. For each path entry that is searched,
147+
:data:`sys.path_importer_cache` is checked. If an non-false object is
148+
found then it is used as the :term:`finder` to query for the module
149+
being searched for. For no entry is found in
150+
:data:`sys.path_importer_cache`, then :data:`sys.path_hooks` is
151+
searched for a finder for the path entry and, if found, is stored in
152+
:data:`sys.path_importer_cache` along with being queried about the
153+
module.

Lib/importlib/NOTES

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ to do
5252
+ machinery
5353

5454
- (?) Chained path hook/finder
55-
- (?) FileFinder
5655
- Extensions importers
5756

5857
* ExtensionFinder
@@ -65,6 +64,11 @@ to do
6564

6665
- PathFinder
6766

67+
* Make sure that there is documentation *somewhere* fully explaining the
68+
semantics of import that can be referenced from the package's documentation
69+
(even if it is in the package documentation itself, although it might be best
70+
in the language specification).
71+
6872
* Write benchmark suite.
6973

7074
* OPTIMIZE!

0 commit comments

Comments
 (0)