corelp.getmodule module
- corelp.getmodule(file)[source]
This function is to be used in a library __init__ file. It creates lazy imports of the module imported and defines __getattr__ and __all__ for this library.
- Parameters:
file (str) – __file__ string in the __init__.py file.
- Returns:
_getattr (function) – Function to replace __getattr__ variable.
_all (list) – list of module names corresponding to __all__.
- Raises:
AttributeError – When trying to import a module which is not in the library.
Examples
>>> from corelp import getmodule ... >>> # In __init__.py file ... __getattr__, __all__ = getmodule(__file__)