class_docstr: This class takes the module name as a parameter, and acts as a proxy for
  that module, importing it only when the module is used, but effectively
  acting as the module in every other way (including inside IPython with
  respect to introspection and tab completion) with the *exception* of
  reload()- reloading a :class:`LazyImport` raises an :class:`ImportError`.
  
  >>> mlab = LazyImport('matplotlib.mlab')
  
  No import happens on the above line, until we do something like call an
  ``mlab`` method or try to do tab completion or introspection on ``mlab``
  in IPython.
  
  >>> mlab
  <module 'matplotlib.mlab' will be lazily loaded>
  
  Now the :class:`LazyImport` will do an actual import, and call the dist
  function of the imported module.
  
  >>> mlab.dist(1969,2011)
  42.0
class_docstr_tok: ["This","class","takes","the","module","name","as","a","parameter",",","and","acts","as","a","proxy","for","that","module",",","importing","it","only","when","the","module","is","used",",","but","effectively","acting","as","the","module","in","every","other","way","(","including","inside","IPython","with","respect","to","introspection","and","tab","completion",")","with","the","*","exception","*","of","reload","(",")","-","reloading","a",":","class",":","`","LazyImport","`","raises","an",":","class",":","`","ImportError","`",".",">",">",">","mlab","=","LazyImport","(","'matplotlib.mlab","'",")","No","import","happens","on","the","above","line",",","until","we","do","something","like","call","an","``","mlab","``","method","or","try","to","do","tab","completion","or","introspection","on","``","mlab","``","in","IPython",".",">",">",">","mlab","<","module","'matplotlib.mlab","'","will","be","lazily","loaded",">","Now","the",":","class",":","`","LazyImport","`","will","do","an","actual","import",",","and","call","the","dist","function","of","the","imported","module",".",">",">",">","mlab.dist","(","1969,2011",")","42.0"]
code: def __getattribute__(self, x):
      # This method will be called only once, since we'll change
      # self.__class__ to LoadedLazyImport, and __getattribute__ will point
      # to module.__getattribute__
  
      name = object.__getattribute__(self, "__name__")
      __import__(name)
  
      # if name above is 'package.foo.bar', package is returned, the docs
      # recommend that in order to get back the full thing, that we import
      # and then lookup the full name is sys.modules, see:
      # http://docs.python.org/library/functions.html#__import__
  
      module = sys.modules[name]
  
      # Now that we've done the import, cutout the middleman and make self
      # act as the imported module
  
      class LoadedLazyImport(types.ModuleType):
          __getattribute__ = module.__getattribute__
          __repr__ = module.__repr__
  
      object.__setattr__(self, "__class__", LoadedLazyImport)
  
      # The next line will make "reload(l)" a silent no-op
      return module.__getattribute__(x)
  
imports: import os
  import sys
  import types
label_desc: Use image node_id 1 for calling the LazyImport obj's underlying member method code with example usage: obj.__getattribute__(x) and returns: module