Cope 2.5.0
My personal "standard library" of all the generally useful code I've written for various projects over the years
Loading...
Searching...
No Matches

◆ ensure_imported()

def Cope.imports.ensure_imported (   package,
str  pip_name = ... 
)

A decorator to ensure that package is not None, and if it is, raise an ImportError telling the user what package needs to be installed.

The package is assumed to be the same name as the name of the variable passed to package. If it's not, be sure to set pip_name to the proper value.

Note that package is either a module or None. It's meant to be used with the lazy_import() function. This does no actual checking if the package is actually installed or not.

This decorator only works with functions. To use with a class, decorate init()

Definition at line 26 of file imports.py.