doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
exec_module(module)
An abstract method that executes the module in its own namespace when a module is imported or reloaded. The module should already be initialized when exec_module() is called. When this method exists, create_module() must be defined. New in version 3.4. Changed in version 3.6: create_module() mu... | python.library.importlib#importlib.abc.Loader.exec_module |
load_module(fullname)
A legacy method for loading a module. If the module cannot be loaded, ImportError is raised, otherwise the loaded module is returned. If the requested module already exists in sys.modules, that module should be used and reloaded. Otherwise the loader should create a new module and insert it into... | python.library.importlib#importlib.abc.Loader.load_module |
module_repr(module)
A legacy method which when implemented calculates and returns the given module’s repr, as a string. The module type’s default repr() will use the result of this method as appropriate. New in version 3.3. Changed in version 3.4: Made optional instead of an abstractmethod. Deprecated since vers... | python.library.importlib#importlib.abc.Loader.module_repr |
class importlib.abc.MetaPathFinder
An abstract base class representing a meta path finder. For compatibility, this is a subclass of Finder. New in version 3.3.
find_spec(fullname, path, target=None)
An abstract method for finding a spec for the specified module. If this is a top-level import, path will be None.... | python.library.importlib#importlib.abc.MetaPathFinder |
find_module(fullname, path)
A legacy method for finding a loader for the specified module. If this is a top-level import, path will be None. Otherwise, this is a search for a subpackage or module and path will be the value of __path__ from the parent package. If a loader cannot be found, None is returned. If find_spe... | python.library.importlib#importlib.abc.MetaPathFinder.find_module |
find_spec(fullname, path, target=None)
An abstract method for finding a spec for the specified module. If this is a top-level import, path will be None. Otherwise, this is a search for a subpackage or module and path will be the value of __path__ from the parent package. If a spec cannot be found, None is returned. W... | python.library.importlib#importlib.abc.MetaPathFinder.find_spec |
invalidate_caches()
An optional method which, when called, should invalidate any internal cache used by the finder. Used by importlib.invalidate_caches() when invalidating the caches of all finders on sys.meta_path. Changed in version 3.4: Returns None when called instead of NotImplemented. | python.library.importlib#importlib.abc.MetaPathFinder.invalidate_caches |
class importlib.abc.PathEntryFinder
An abstract base class representing a path entry finder. Though it bears some similarities to MetaPathFinder, PathEntryFinder is meant for use only within the path-based import subsystem provided by PathFinder. This ABC is a subclass of Finder for compatibility reasons only. New i... | python.library.importlib#importlib.abc.PathEntryFinder |
find_loader(fullname)
A legacy method for finding a loader for the specified module. Returns a 2-tuple of (loader, portion) where portion is a sequence of file system locations contributing to part of a namespace package. The loader may be None while specifying portion to signify the contribution of the file system l... | python.library.importlib#importlib.abc.PathEntryFinder.find_loader |
find_module(fullname)
A concrete implementation of Finder.find_module() which is equivalent to self.find_loader(fullname)[0]. Deprecated since version 3.4: Use find_spec() instead. | python.library.importlib#importlib.abc.PathEntryFinder.find_module |
find_spec(fullname, target=None)
An abstract method for finding a spec for the specified module. The finder will search for the module only within the path entry to which it is assigned. If a spec cannot be found, None is returned. When passed in, target is a module object that the finder may use to make a more educa... | python.library.importlib#importlib.abc.PathEntryFinder.find_spec |
invalidate_caches()
An optional method which, when called, should invalidate any internal cache used by the finder. Used by PathFinder.invalidate_caches() when invalidating the caches of all cached finders. | python.library.importlib#importlib.abc.PathEntryFinder.invalidate_caches |
class importlib.abc.ResourceLoader
An abstract base class for a loader which implements the optional PEP 302 protocol for loading arbitrary resources from the storage back-end. Deprecated since version 3.7: This ABC is deprecated in favour of supporting resource loading through importlib.abc.ResourceReader.
abstr... | python.library.importlib#importlib.abc.ResourceLoader |
abstractmethod get_data(path)
An abstract method to return the bytes for the data located at path. Loaders that have a file-like storage back-end that allows storing arbitrary data can implement this abstract method to give direct access to the data stored. OSError is to be raised if the path cannot be found. The pat... | python.library.importlib#importlib.abc.ResourceLoader.get_data |
class importlib.abc.ResourceReader
Superseded by TraversableReader An abstract base class to provide the ability to read resources. From the perspective of this ABC, a resource is a binary artifact that is shipped within a package. Typically this is something like a data file that lives next to the __init__.py file o... | python.library.importlib#importlib.abc.ResourceReader |
abstractmethod contents()
Returns an iterable of strings over the contents of the package. Do note that it is not required that all names returned by the iterator be actual resources, e.g. it is acceptable to return names for which is_resource() would be false. Allowing non-resource names to be returned is to allow f... | python.library.importlib#importlib.abc.ResourceReader.contents |
abstractmethod is_resource(name)
Returns True if the named name is considered a resource. FileNotFoundError is raised if name does not exist. | python.library.importlib#importlib.abc.ResourceReader.is_resource |
abstractmethod open_resource(resource)
Returns an opened, file-like object for binary reading of the resource. If the resource cannot be found, FileNotFoundError is raised. | python.library.importlib#importlib.abc.ResourceReader.open_resource |
abstractmethod resource_path(resource)
Returns the file system path to the resource. If the resource does not concretely exist on the file system, raise FileNotFoundError. | python.library.importlib#importlib.abc.ResourceReader.resource_path |
class importlib.abc.SourceLoader
An abstract base class for implementing source (and optionally bytecode) file loading. The class inherits from both ResourceLoader and ExecutionLoader, requiring the implementation of: ResourceLoader.get_data()
ExecutionLoader.get_filename()
Should only return the path to the so... | python.library.importlib#importlib.abc.SourceLoader |
exec_module(module)
Concrete implementation of Loader.exec_module(). New in version 3.4. | python.library.importlib#importlib.abc.SourceLoader.exec_module |
get_code(fullname)
Concrete implementation of InspectLoader.get_code(). | python.library.importlib#importlib.abc.SourceLoader.get_code |
get_source(fullname)
Concrete implementation of InspectLoader.get_source(). | python.library.importlib#importlib.abc.SourceLoader.get_source |
is_package(fullname)
Concrete implementation of InspectLoader.is_package(). A module is determined to be a package if its file path (as provided by ExecutionLoader.get_filename()) is a file named __init__ when the file extension is removed and the module name itself does not end in __init__. | python.library.importlib#importlib.abc.SourceLoader.is_package |
load_module(fullname)
Concrete implementation of Loader.load_module(). Deprecated since version 3.4: Use exec_module() instead. | python.library.importlib#importlib.abc.SourceLoader.load_module |
path_mtime(path)
Optional abstract method which returns the modification time for the specified path. Deprecated since version 3.3: This method is deprecated in favour of path_stats(). You don’t have to implement it, but it is still available for compatibility purposes. Raise OSError if the path cannot be handled. ... | python.library.importlib#importlib.abc.SourceLoader.path_mtime |
path_stats(path)
Optional abstract method which returns a dict containing metadata about the specified path. Supported dictionary keys are:
'mtime' (mandatory): an integer or floating-point number representing the modification time of the source code;
'size' (optional): the size in bytes of the source code. Any o... | python.library.importlib#importlib.abc.SourceLoader.path_stats |
set_data(path, data)
Optional abstract method which writes the specified bytes to a file path. Any intermediate directories which do not exist are to be created automatically. When writing to the path fails because the path is read-only (errno.EACCES/PermissionError), do not propagate the exception. Changed in versi... | python.library.importlib#importlib.abc.SourceLoader.set_data |
class importlib.abc.Traversable
An object with a subset of pathlib.Path methods suitable for traversing directories and opening files. New in version 3.9. | python.library.importlib#importlib.abc.Traversable |
class importlib.abc.TraversableReader
An abstract base class for resource readers capable of serving the files interface. Subclasses ResourceReader and provides concrete implementations of the ResourceReader’s abstract methods. Therefore, any loader supplying TraversableReader also supplies ResourceReader. New in ve... | python.library.importlib#importlib.abc.TraversableReader |
importlib.find_loader(name, path=None)
Find the loader for a module, optionally within the specified path. If the module is in sys.modules, then sys.modules[name].__loader__ is returned (unless the loader would be None or is not set, in which case ValueError is raised). Otherwise a search using sys.meta_path is done.... | python.library.importlib#importlib.find_loader |
importlib.import_module(name, package=None)
Import a module. The name argument specifies what module to import in absolute or relative terms (e.g. either pkg.mod or ..mod). If the name is specified in relative terms, then the package argument must be set to the name of the package which is to act as the anchor for re... | python.library.importlib#importlib.import_module |
importlib.invalidate_caches()
Invalidate the internal caches of finders stored at sys.meta_path. If a finder implements invalidate_caches() then it will be called to perform the invalidation. This function should be called if any modules are created/installed while your program is running to guarantee all finders wil... | python.library.importlib#importlib.invalidate_caches |
importlib.machinery.all_suffixes()
Returns a combined list of strings representing all file suffixes for modules recognized by the standard import machinery. This is a helper for code which simply needs to know if a filesystem path potentially refers to a module without needing any details on the kind of module (for ... | python.library.importlib#importlib.machinery.all_suffixes |
class importlib.machinery.BuiltinImporter
An importer for built-in modules. All known built-in modules are listed in sys.builtin_module_names. This class implements the importlib.abc.MetaPathFinder and importlib.abc.InspectLoader ABCs. Only class methods are defined by this class to alleviate the need for instantiati... | python.library.importlib#importlib.machinery.BuiltinImporter |
importlib.machinery.BYTECODE_SUFFIXES
A list of strings representing the recognized file suffixes for bytecode modules (including the leading dot). New in version 3.3. Changed in version 3.5: The value is no longer dependent on __debug__. | python.library.importlib#importlib.machinery.BYTECODE_SUFFIXES |
importlib.machinery.DEBUG_BYTECODE_SUFFIXES
A list of strings representing the file suffixes for non-optimized bytecode modules. New in version 3.3. Deprecated since version 3.5: Use BYTECODE_SUFFIXES instead. | python.library.importlib#importlib.machinery.DEBUG_BYTECODE_SUFFIXES |
class importlib.machinery.ExtensionFileLoader(fullname, path)
A concrete implementation of importlib.abc.ExecutionLoader for extension modules. The fullname argument specifies the name of the module the loader is to support. The path argument is the path to the extension module’s file. New in version 3.3.
name
... | python.library.importlib#importlib.machinery.ExtensionFileLoader |
create_module(spec)
Creates the module object from the given specification in accordance with PEP 489. New in version 3.5. | python.library.importlib#importlib.machinery.ExtensionFileLoader.create_module |
exec_module(module)
Initializes the given module object in accordance with PEP 489. New in version 3.5. | python.library.importlib#importlib.machinery.ExtensionFileLoader.exec_module |
get_code(fullname)
Returns None as extension modules lack a code object. | python.library.importlib#importlib.machinery.ExtensionFileLoader.get_code |
get_filename(fullname)
Returns path. New in version 3.4. | python.library.importlib#importlib.machinery.ExtensionFileLoader.get_filename |
get_source(fullname)
Returns None as extension modules do not have source code. | python.library.importlib#importlib.machinery.ExtensionFileLoader.get_source |
is_package(fullname)
Returns True if the file path points to a package’s __init__ module based on EXTENSION_SUFFIXES. | python.library.importlib#importlib.machinery.ExtensionFileLoader.is_package |
name
Name of the module the loader supports. | python.library.importlib#importlib.machinery.ExtensionFileLoader.name |
path
Path to the extension module. | python.library.importlib#importlib.machinery.ExtensionFileLoader.path |
importlib.machinery.EXTENSION_SUFFIXES
A list of strings representing the recognized file suffixes for extension modules. New in version 3.3. | python.library.importlib#importlib.machinery.EXTENSION_SUFFIXES |
class importlib.machinery.FileFinder(path, *loader_details)
A concrete implementation of importlib.abc.PathEntryFinder which caches results from the file system. The path argument is the directory for which the finder is in charge of searching. The loader_details argument is a variable number of 2-item tuples each co... | python.library.importlib#importlib.machinery.FileFinder |
find_loader(fullname)
Attempt to find the loader to handle fullname within path. | python.library.importlib#importlib.machinery.FileFinder.find_loader |
find_spec(fullname, target=None)
Attempt to find the spec to handle fullname within path. New in version 3.4. | python.library.importlib#importlib.machinery.FileFinder.find_spec |
invalidate_caches()
Clear out the internal cache. | python.library.importlib#importlib.machinery.FileFinder.invalidate_caches |
path
The path the finder will search in. | python.library.importlib#importlib.machinery.FileFinder.path |
classmethod path_hook(*loader_details)
A class method which returns a closure for use on sys.path_hooks. An instance of FileFinder is returned by the closure using the path argument given to the closure directly and loader_details indirectly. If the argument to the closure is not an existing directory, ImportError is... | python.library.importlib#importlib.machinery.FileFinder.path_hook |
class importlib.machinery.FrozenImporter
An importer for frozen modules. This class implements the importlib.abc.MetaPathFinder and importlib.abc.InspectLoader ABCs. Only class methods are defined by this class to alleviate the need for instantiation. Changed in version 3.4: Gained create_module() and exec_module() ... | python.library.importlib#importlib.machinery.FrozenImporter |
class importlib.machinery.ModuleSpec(name, loader, *, origin=None, loader_state=None, is_package=None)
A specification for a module’s import-system-related state. This is typically exposed as the module’s __spec__ attribute. In the descriptions below, the names in parentheses give the corresponding attribute availabl... | python.library.importlib#importlib.machinery.ModuleSpec |
cached | python.library.importlib#importlib.machinery.ModuleSpec.cached |
has_location | python.library.importlib#importlib.machinery.ModuleSpec.has_location |
loader | python.library.importlib#importlib.machinery.ModuleSpec.loader |
loader_state | python.library.importlib#importlib.machinery.ModuleSpec.loader_state |
name | python.library.importlib#importlib.machinery.ModuleSpec.name |
origin | python.library.importlib#importlib.machinery.ModuleSpec.origin |
parent | python.library.importlib#importlib.machinery.ModuleSpec.parent |
submodule_search_locations | python.library.importlib#importlib.machinery.ModuleSpec.submodule_search_locations |
importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES
A list of strings representing the file suffixes for optimized bytecode modules. New in version 3.3. Deprecated since version 3.5: Use BYTECODE_SUFFIXES instead. | python.library.importlib#importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES |
class importlib.machinery.PathFinder
A Finder for sys.path and package __path__ attributes. This class implements the importlib.abc.MetaPathFinder ABC. Only class methods are defined by this class to alleviate the need for instantiation.
classmethod find_spec(fullname, path=None, target=None)
Class method that at... | python.library.importlib#importlib.machinery.PathFinder |
classmethod find_module(fullname, path=None)
A legacy wrapper around find_spec(). Deprecated since version 3.4: Use find_spec() instead. | python.library.importlib#importlib.machinery.PathFinder.find_module |
classmethod find_spec(fullname, path=None, target=None)
Class method that attempts to find a spec for the module specified by fullname on sys.path or, if defined, on path. For each path entry that is searched, sys.path_importer_cache is checked. If a non-false object is found then it is used as the path entry finder ... | python.library.importlib#importlib.machinery.PathFinder.find_spec |
classmethod invalidate_caches()
Calls importlib.abc.PathEntryFinder.invalidate_caches() on all finders stored in sys.path_importer_cache that define the method. Otherwise entries in sys.path_importer_cache set to None are deleted. Changed in version 3.7: Entries of None in sys.path_importer_cache are deleted. | python.library.importlib#importlib.machinery.PathFinder.invalidate_caches |
class importlib.machinery.SourceFileLoader(fullname, path)
A concrete implementation of importlib.abc.SourceLoader by subclassing importlib.abc.FileLoader and providing some concrete implementations of other methods. New in version 3.3.
name
The name of the module that this loader will handle.
path
The pa... | python.library.importlib#importlib.machinery.SourceFileLoader |
is_package(fullname)
Return True if path appears to be for a package. | python.library.importlib#importlib.machinery.SourceFileLoader.is_package |
load_module(name=None)
Concrete implementation of importlib.abc.Loader.load_module() where specifying the name of the module to load is optional. Deprecated since version 3.6: Use importlib.abc.Loader.exec_module() instead. | python.library.importlib#importlib.machinery.SourceFileLoader.load_module |
name
The name of the module that this loader will handle. | python.library.importlib#importlib.machinery.SourceFileLoader.name |
path
The path to the source file. | python.library.importlib#importlib.machinery.SourceFileLoader.path |
path_stats(path)
Concrete implementation of importlib.abc.SourceLoader.path_stats(). | python.library.importlib#importlib.machinery.SourceFileLoader.path_stats |
set_data(path, data)
Concrete implementation of importlib.abc.SourceLoader.set_data(). | python.library.importlib#importlib.machinery.SourceFileLoader.set_data |
class importlib.machinery.SourcelessFileLoader(fullname, path)
A concrete implementation of importlib.abc.FileLoader which can import bytecode files (i.e. no source code files exist). Please note that direct use of bytecode files (and thus not source code files) inhibits your modules from being usable by all Python i... | python.library.importlib#importlib.machinery.SourcelessFileLoader |
get_code(fullname)
Returns the code object for name created from path. | python.library.importlib#importlib.machinery.SourcelessFileLoader.get_code |
get_source(fullname)
Returns None as bytecode files have no source when this loader is used. | python.library.importlib#importlib.machinery.SourcelessFileLoader.get_source |
is_package(fullname)
Determines if the module is a package based on path. | python.library.importlib#importlib.machinery.SourcelessFileLoader.is_package |
load_module(name=None) | python.library.importlib#importlib.machinery.SourcelessFileLoader.load_module |
name
The name of the module the loader will handle. | python.library.importlib#importlib.machinery.SourcelessFileLoader.name |
path
The path to the bytecode file. | python.library.importlib#importlib.machinery.SourcelessFileLoader.path |
importlib.machinery.SOURCE_SUFFIXES
A list of strings representing the recognized file suffixes for source modules. New in version 3.3. | python.library.importlib#importlib.machinery.SOURCE_SUFFIXES |
class importlib.machinery.WindowsRegistryFinder
Finder for modules declared in the Windows registry. This class implements the importlib.abc.MetaPathFinder ABC. Only class methods are defined by this class to alleviate the need for instantiation. New in version 3.3. Deprecated since version 3.6: Use site configura... | python.library.importlib#importlib.machinery.WindowsRegistryFinder |
importlib.reload(module)
Reload a previously imported module. The argument must be a module object, so it must have been successfully imported before. This is useful if you have edited the module source file using an external editor and want to try out the new version without leaving the Python interpreter. The retur... | python.library.importlib#importlib.reload |
importlib.resources.as_file(traversable)
Given a importlib.resources.abc.Traversable object representing a file, typically from importlib.resources.files(), return a context manager for use in a with statement. The context manager provides a pathlib.Path object. Exiting the context manager cleans up any temporary fil... | python.library.importlib#importlib.resources.as_file |
importlib.resources.contents(package)
Return an iterable over the named items within the package. The iterable returns str resources (e.g. files) and non-resources (e.g. directories). The iterable does not recurse into subdirectories. package is either a name or a module object which conforms to the Package requireme... | python.library.importlib#importlib.resources.contents |
importlib.resources.files(package)
Returns an importlib.resources.abc.Traversable object representing the resource container for the package (think directory) and its resources (think files). A Traversable may contain other containers (think subdirectories). package is either a name or a module object which conforms ... | python.library.importlib#importlib.resources.files |
importlib.resources.is_resource(package, name)
Return True if there is a resource named name in the package, otherwise False. Remember that directories are not resources! package is either a name or a module object which conforms to the Package requirements. | python.library.importlib#importlib.resources.is_resource |
importlib.resources.open_binary(package, resource)
Open for binary reading the resource within package. package is either a name or a module object which conforms to the Package requirements. resource is the name of the resource to open within package; it may not contain path separators and it may not have sub-resour... | python.library.importlib#importlib.resources.open_binary |
importlib.resources.open_text(package, resource, encoding='utf-8', errors='strict')
Open for text reading the resource within package. By default, the resource is opened for reading as UTF-8. package is either a name or a module object which conforms to the Package requirements. resource is the name of the resource t... | python.library.importlib#importlib.resources.open_text |
importlib.resources.Package
The Package type is defined as Union[str, ModuleType]. This means that where the function describes accepting a Package, you can pass in either a string or a module. Module objects must have a resolvable __spec__.submodule_search_locations that is not None. | python.library.importlib#importlib.resources.Package |
importlib.resources.path(package, resource)
Return the path to the resource as an actual file system path. This function returns a context manager for use in a with statement. The context manager provides a pathlib.Path object. Exiting the context manager cleans up any temporary file created when the resource needs t... | python.library.importlib#importlib.resources.path |
importlib.resources.read_binary(package, resource)
Read and return the contents of the resource within package as bytes. package is either a name or a module object which conforms to the Package requirements. resource is the name of the resource to open within package; it may not contain path separators and it may no... | python.library.importlib#importlib.resources.read_binary |
importlib.resources.read_text(package, resource, encoding='utf-8', errors='strict')
Read and return the contents of resource within package as a str. By default, the contents are read as strict UTF-8. package is either a name or a module object which conforms to the Package requirements. resource is the name of the r... | python.library.importlib#importlib.resources.read_text |
importlib.resources.Resource
This type describes the resource names passed into the various functions in this package. This is defined as Union[str, os.PathLike]. | python.library.importlib#importlib.resources.Resource |
importlib.util.cache_from_source(path, debug_override=None, *, optimization=None)
Return the PEP 3147/PEP 488 path to the byte-compiled file associated with the source path. For example, if path is /foo/bar/baz.py the return value would be /foo/bar/__pycache__/baz.cpython-32.pyc for Python 3.2. The cpython-32 string ... | python.library.importlib#importlib.util.cache_from_source |
importlib.util.decode_source(source_bytes)
Decode the given bytes representing source code and return it as a string with universal newlines (as required by importlib.abc.InspectLoader.get_source()). New in version 3.4. | python.library.importlib#importlib.util.decode_source |
importlib.util.find_spec(name, package=None)
Find the spec for a module, optionally relative to the specified package name. If the module is in sys.modules, then sys.modules[name].__spec__ is returned (unless the spec would be None or is not set, in which case ValueError is raised). Otherwise a search using sys.meta_... | python.library.importlib#importlib.util.find_spec |
class importlib.util.LazyLoader(loader)
A class which postpones the execution of the loader of a module until the module has an attribute accessed. This class only works with loaders that define exec_module() as control over what module type is used for the module is required. For those same reasons, the loader’s cre... | python.library.importlib#importlib.util.LazyLoader |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.