parameters: (module_path)
return_statement: return module
docstring: Load a module given only the path name.
  
    Also loads package modules as necessary.
  
    Args:
      module_path: An absolute path to a python module.
    Returns:
      The module object for the given path.
docstring_summary: Load a module given only the path name.
docstring_tokens: Load a module given only the path name .
function: def load_module_from_path(module_path):
    """Load a module given only the path name.
  
    Also loads package modules as necessary.
  
    Args:
      module_path: An absolute path to a python module.
    Returns:
      The module object for the given path.
    """
    module_names = [os.path.splitext(os.path.basename(module_path))[0]]
    d = os.path.dirname(module_path)
  
    while os.path.exists(os.path.join(d, '__init__.py')):
      module_names.append(os.path.basename(d))
      d = os.path.dirname(d)
  
    d = [d]
  
    module = None
    full_module_name = ''
    for package_name in reversed(module_names):
      if module:
        d = module.__path__
        full_module_name += '.'
      r = imp.find_module(package_name, d)
      full_module_name += package_name
      module = imp.load_module(full_module_name, *r)
    return module
function_tokens: def load_module_from_path ( module_path ) : module_names = [ os . path . splitext ( os . path . basename ( module_path ) ) [ 0 ] ] d = os . path . dirname ( module_path ) while os . path . exists ( os . path . join ( d , '__init__.py' ) ) : module_names . append ( os . path . basename ( d ) ) d = os . path . dirname ( d ) d = [ d ] module = None full_module_name = '' for package_name in reversed ( module_names ) : if module : d = module . __path__ full_module_name += '.' r = imp . find_module ( package_name , d ) full_module_name += package_name module = imp . load_module ( full_module_name , * r ) return module