Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
23b8ddc1
Commit
23b8ddc1
authored
Aug 28, 2007
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some glitches.
parent
99cafb99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
Doc/library/imputil.rst
Doc/library/imputil.rst
+20
-19
No files found.
Doc/library/imputil.rst
View file @
23b8ddc1
...
@@ -3,15 +3,15 @@
...
@@ -3,15 +3,15 @@
=====================================================
=====================================================
.. module:: imputil
.. module:: imputil
:synopsis: Manage and augment the import process
:synopsis: Manage and augment the import process
.
.. index:: statement: import
.. index:: statement: import
This module provides a very handy and useful mechanism for custom
This module provides a very handy and useful mechanism for custom
:keyword:`import` hooks. Compared to the
standard library's ihooks.py
,
:keyword:`import` hooks. Compared to the
older :mod:`ihooks` module
,
imputil.py takes a dramatically simpler and more straight-forward approach
:mod:`imputil` takes a dramatically simpler and more straight-forward
to custom :keyword:`import` functions.
approach
to custom :keyword:`import` functions.
.. class:: ImportManager([fs_imp])
.. class:: ImportManager([fs_imp])
...
@@ -43,40 +43,40 @@ to custom :keyword:`import` functions.
...
@@ -43,40 +43,40 @@ to custom :keyword:`import` functions.
Find and retrieve the code for the given module.
Find and retrieve the code for the given module.
parent specifies a parent module to define a context for importing. It
*parent* specifies a parent module to define a context for importing.
may be None
, indicating no particular context for the search.
It may be ``None``
, indicating no particular context for the search.
modname
specifies a single module (not dotted) within the parent.
*modname*
specifies a single module (not dotted) within the parent.
fqname
specifies the fully-qualified module name. This is a
*fqname*
specifies the fully-qualified module name. This is a
(potentially) dotted name from the "root" of the module namespace
(potentially) dotted name from the "root" of the module namespace
down to the modname.
down to the modname.
If there is no parent, then modname==fqname.
If there is no parent, then modname==fqname.
This method should return
None
, or a 3-tuple.
This method should return
``None``
, or a 3-tuple.
* If the module was not found, then
None
should be returned.
* If the module was not found, then
``None``
should be returned.
* The first item of the 2- or 3-tuple should be the integer 0 or 1,
* The first item of the 2- or 3-tuple should be the integer 0 or 1,
specifying whether the module that was found is a package or not.
specifying whether the module that was found is a package or not.
* The second item is the code object for the module (it will be
* The second item is the code object for the module (it will be
executed within the new module's namespace). This item can also
executed within the new module's namespace). This item can also
be a fully-loaded module object (e.g. loaded from a shared lib).
be a fully-loaded module object (e.g. loaded from a shared lib).
* The third item is a dictionary of name/value pairs that will be
* The third item is a dictionary of name/value pairs that will be
inserted into new module before the code object is executed. This
inserted into new module before the code object is executed. This
is provided in case the module's code expects certain values (such
is provided in case the module's code expects certain values (such
as where the module was found). When the second item is a module
as where the module was found). When the second item is a module
object, then these names/values will be inserted *after* the module
object, then these names/values will be inserted *after* the module
has been loaded/initialized.
has been loaded/initialized.
.. class:: BuiltinImporter()
.. class:: BuiltinImporter()
Emulate the import mechanism for builtin and frozen modules. This is a
Emulate the import mechanism for builtin and frozen modules. This is a
sub-class of the
Importer module
.
sub-class of the
:class:`Importer` class
.
.. method:: BuiltinImporter.get_code(parent, modname, fqname)
.. method:: BuiltinImporter.get_code(parent, modname, fqname)
...
@@ -106,6 +106,7 @@ This code is intended to be read, not executed. However, it does work
...
@@ -106,6 +106,7 @@ This code is intended to be read, not executed. However, it does work
(The name is a pun on the klunkier predecessor of this module, "ni".)
(The name is a pun on the klunkier predecessor of this module, "ni".)
::
import sys, imp, __builtin__
import sys, imp, __builtin__
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment