importlib.machinery.all_suffixes()

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 example, inspect.getmodulename()). New in version 3.3.

importlib.invalidate_caches()

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 will notice the new module’s existence. New in version 3.3.

importlib.import_module()

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 resolving the package name (e.g. import_module('..mod', 'pkg.subpkg') will import pkg.mod). The import_module() function acts as a simplifying wrapper around importlib.__import__()

importlib.find_loader()

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. None is returned if no loader is found. A dotted name does not have its parent’s implicitly imported as that requires loading them and that may not be desired. To properly impor

importlib.abc.SourceLoader.set_data()

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 version 3.4: No longer raises NotImplementedError when called.

importlib.abc.SourceLoader.path_stats()

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 other keys in the dictionary are ignored, to allow for future extensions. If the path cannot be handled, OSError is raised. New in version 3.3. Changed in version 3.4: Raise OS

importlib.abc.SourceLoader.path_mtime()

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. Changed in version 3.4: Raise OSError instead of NotImplementedError.

importlib.abc.SourceLoader.load_module()

load_module(fullname) Concrete implementation of Loader.load_module(). Deprecated since version 3.4: Use exec_module() instead.

importlib.abc.SourceLoader.is_package()

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__.

importlib.abc.SourceLoader.get_source()

get_source(fullname) Concrete implementation of InspectLoader.get_source().