k1lib.imports module

These are pretty standard imports that I always do. I put it here so that I can do:

from k1lib.imports import *

and everything will be in place

class k1lib.imports._OptionalImports[source]

Bases: object

This class is supposed to be a singleton, with the object at k1lib.imports.OptionalImports. The idea is, you can create libraries that has function funcA, which uses numpy. However, you don’t want to declare your library that it depends on numpy, so if the user does not have numpy, you can print something out

__call__(module: str, force=False)[source]

Tries to import the module. If successful, return the module, else return None

Parameters

force – If True, then errors out if can’t import module

__contains__(module: str)[source]

Whether someone already tried to import a module.