class LazyModule(module, variable, namespace=None, overwrite=True)[source]#

Bases: object

Create a “lazy” module that is loaded if and only if an attribute is called.

Typically not for use by the user, but is used by sc.importbyname().

  • module (str) – name of the module to (not) load

  • variable (str) – variable name to assign the module to

  • namespace (dict) – the namespace to use (if not supplied, globals())

  • overwrite (bool) – whether to allow overwriting an existing variable (by default, yes)


pd = sc.LazyModule('pandas', 'pd') # pd is a LazyModule, not actually pandas
df = pd.DataFrame() # Not only does this work, but pd is now actually pandas

New in version 2.0.0.