Since PEP 302 still serves as the de facto documentation of the import loader system, mention the new optional loader extension introduced by PEP 338
This commit is contained in:
parent
f4ecc494de
commit
bf253555cd
24
pep-0302.txt
24
pep-0302.txt
|
@ -360,12 +360,13 @@ Packages and the role of __path__
|
|||
|
||||
Optional Extensions to the Importer Protocol
|
||||
|
||||
The Importer Protocol defines two optional extensions. One is to
|
||||
retrieve data files, the other is to support module packaging tools
|
||||
The Importer Protocol defines three optional extensions. One is to
|
||||
retrieve data files, the second is to support module packaging tools
|
||||
and/or tools that analyze module dependencies (for example Freeze
|
||||
[3]). The latter category of tools usually don't actually *load*
|
||||
[3]), while the last is to support execution of modules as scripts.
|
||||
The latter two categories of tools usually don't actually *load*
|
||||
modules, they only need to know if and where they are available.
|
||||
Both extensions are highly recommended for general purpose
|
||||
All three extensions are highly recommended for general purpose
|
||||
importers, but may safely be left out if those features aren't
|
||||
needed.
|
||||
|
||||
|
@ -413,6 +414,18 @@ Optional Extensions to the Importer Protocol
|
|||
raise ImportError if the module can't be found by the importer at
|
||||
all).
|
||||
|
||||
To support execution of modules as scripts [9], the above three
|
||||
methods for finding the code associated with a module must be
|
||||
implemented. In addition to those methods, the following method
|
||||
may be provided in order to allow the ``runpy`` module to correctly
|
||||
set the ``__file__`` attribute:
|
||||
|
||||
loader.get_filename(fullname)
|
||||
|
||||
This method should return the value that ``__file__`` would be set
|
||||
to if the named module was loaded. If the module is not found, then
|
||||
ImportError should be raised.
|
||||
|
||||
|
||||
Integration with the 'imp' module
|
||||
|
||||
|
@ -575,6 +588,9 @@ References and Footnotes
|
|||
[8] Quixote, a framework for developing Web applications
|
||||
http://www.mems-exchange.org/software/quixote/
|
||||
|
||||
[9] PEP 338: Executing modules as scripts
|
||||
http://www.python.org/dev/peps/pep-0338/
|
||||
|
||||
|
||||
Copyright
|
||||
|
||||
|
|
Loading…
Reference in New Issue