imports#

This module contains LazyModule class for lazy importing of modules and a simple package availability check.

It is not intended for regular importing, as it works as the __init__.py namespace resident - it can be assigned to sys.modules[__name__] in order to perform lazy loading of modules by passing just the import structure instead of imported models.

For example implementation, check out the __init__.py script of this package!

LazyModule#

class pocketwelt.imports.LazyModule(module_name: str, module_file: str, import_structure: Dict[str, List[str]])#

Bases: ModuleType

Module for lazy importing.

Heavily based on:

is_package_available#

pocketwelt.imports.is_package_available(name: str) bool#

Use to check for installation of a package. Finding path of the package does not import it, thus we can notify the user if some packages are missing.

Parameters:

name (str) – Name of the package to check.