Package gavo :: Package utils :: Module codetricks :: Class DeferredImport
[frames] | no frames]

Class DeferredImport

source code

object --+
         |
        DeferredImport

A trivial deferred module loader.

Use this to delay the actual import of a module until it's actually
needed.

It is constructed with a module name (that will be inserted into the
calling module's globals() as a side effect) and some literal code
that, when executed in the caller's global namespace, actually
imports the module, for instance::

        utils.DeferredImport("wcs", "from astropy import wcs")

As a service for static code checking, you'll usually want to repeat
the module name, though:


        wcs = utils.DeferredImport("wcs", "from astropy import wcs")

Instance Methods
 
__init__(self, moduleName, loadingCode)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__getattr__(self, name) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  loadedModule = None
hash(x)
Properties

Inherited from object: __class__

Method Details

__init__(self, moduleName, loadingCode)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)