Back to module index
Go to module by name
imp
This module provides the components needed to build your own __import__
function. Undocumented functions are obsolete.
In most cases it is preferred you consider using the importlib module's
functionality over this module.
Classes
NullImporter
Null import object.
find_module(self, fullname)
Always returns None.
SourcelessFileLoader
Loader which handles sourceless file imports.
contents(self)
create_module(self, spec)
Use default semantics for module creation.
exec_module(self, module)
Execute the module.
get_code(self, fullname)
get_data(self, path)
Return the data from path as raw bytes.
get_filename(self, name=None, *args, **kwargs)
Return the path to the source file as found by the finder.
get_resource_reader(self, name=None, *args, **kwargs)
get_source(self, fullname)
Return None as there is no source code.
is_package(self, fullname)
Concrete implementation of InspectLoader.is_package by checking if
the path returned by get_filename has a filename of '__init__.py'.
is_resource(self, name)
load_module(self, name=None, *args, **kwargs)
Load a module from a file.
This method is deprecated. Use exec_module() instead.
open_resource(self, resource)
resource_path(self, resource)
Functions
acquire_lock
acquire_lock()
Acquires the interpreter's import lock for the current thread.
This lock should be used by import hooks to ensure thread-safety when importing
modules. On platforms without threads, this function does nothing.
cache_from_source
cache_from_source(path, debug_override=None)
**DEPRECATED**
Given the path to a .py file, return the path to its .pyc file.
The .py file does not need to exist; this simply returns the path to the
.pyc file calculated as if the .py file were imported.
If debug_override is not None, then it must be a boolean and is used in
place of sys.flags.optimize.
If sys.implementation.cache_tag is None then NotImplementedError is raised.
create_dynamic
create_dynamic(...)
Create an extension module.
find_module
find_module(name, path=None)
**DEPRECATED**
Search for a module.
If path is omitted or None, search for a built-in, frozen or special
module and continue search in sys.path. The module name cannot
contain '.'; to search for a submodule of a package, pass the
submodule name and the package's __path__.
get_frozen_object
get_frozen_object(name, /)
Create a code object for a frozen module.
get_magic
get_magic()
**DEPRECATED**
Return the magic number for .pyc files.
get_suffixes
get_suffixes()
**DEPRECATED**
get_tag
get_tag()
Return the magic tag for .pyc files.
init_builtin
init_builtin(name)
**DEPRECATED**
Load and return a built-in module by name, or None is such module doesn't
exist
init_frozen
init_frozen(name, /)
Initializes a frozen module.
is_builtin
is_builtin(name, /)
Returns True if the module name corresponds to a built-in module.
is_frozen
is_frozen(name, /)
Returns True if the module name corresponds to a frozen module.
is_frozen_package
is_frozen_package(name, /)
Returns True if the module name is of a frozen package.
load_compiled
load_compiled(name, pathname, file=None)
**DEPRECATED**
load_dynamic
load_dynamic(name, path, file=None)
**DEPRECATED**
Load an extension module.
load_module
load_module(name, file, filename, details)
**DEPRECATED**
Load a module, given information returned by find_module().
The module name must include the full package name, if any.
load_package
load_package(name, path)
**DEPRECATED**
load_source
load_source(name, pathname, file=None)
lock_held
lock_held()
Return True if the import lock is currently held, else False.
On platforms without threads, return False.
new_module
new_module(name)
**DEPRECATED**
Create a new module.
The module is not entered into sys.modules.
release_lock
release_lock()
Release the interpreter's import lock.
On platforms without threads, this function does nothing.
reload
reload(module)
**DEPRECATED**
Reload the module and return it.
The module must have been successfully imported before.
source_from_cache
source_from_cache(path)
**DEPRECATED**
Given the path to a .pyc. file, return the path to its .py file.
The .pyc file does not need to exist; this simply returns the path to
the .py file calculated to correspond to the .pyc file. If path does
not conform to PEP 3147 format, ValueError will be raised. If
sys.implementation.cache_tag is None then NotImplementedError is raised.
Other members
C_BUILTIN = 6
C_EXTENSION = 3
IMP_HOOK = 9
PKG_DIRECTORY = 5
PY_CODERESOURCE = 8
PY_COMPILED = 2
PY_FROZEN = 7
PY_RESOURCE = 4
PY_SOURCE = 1
SEARCH_ERROR = 0
Modules
importlib
machinery
os
sys
tokenize
types
util
warnings