(name, globals=None, locals=None, fromlist=(), level=0)
Import a module.

    The 'globals' argument is used to infer where the import is occurring from
    to handle relative imports. The 'locals' argument is ignored. The
    'fromlist' argument specifies what should exist as attributes on the module
    being imported (e.g. ``from module import <fromlist>``).  The 'level'
    argument represents the package location to import from in a relative
    import (e.g. ``from ..pkg import mod`` would have a 'level' of 2).
Import a module.
Import a module .
def __import__(name, globals=None, locals=None, fromlist=(), level=0):
    """Import a module.

    The 'globals' argument is used to infer where the import is occurring from
    to handle relative imports. The 'locals' argument is ignored. The
    'fromlist' argument specifies what should exist as attributes on the module
    being imported (e.g. ``from module import <fromlist>``).  The 'level'
    argument represents the package location to import from in a relative
    import (e.g. ``from ..pkg import mod`` would have a 'level' of 2).

    """
    if level == 0:
        module = _gcd_import(name)
    else:
        globals_ = globals if globals is not None else {}
        package = _calc___package__(globals_)
        module = _gcd_import(name, package, level)
    if not fromlist:
        # Return up to the first dot in 'name'. This is complicated by the fact
        # that 'name' may be relative.
        if level == 0:
            return _gcd_import(name.partition('.')[0])
        elif not name:
            return module
        else:
            # Figure out where to slice the module's name up to the first dot
            # in 'name'.
            cut_off = len(name) - len(name.partition('.')[0])
            # Slice end needs to be positive to alleviate need to special-case
            # when ``'.' not in name``.
            return sys.modules[module.__name__[:len(module.__name__)-cut_off]]
    elif hasattr(module, '__path__'):
        return _handle_fromlist(module, fromlist, _gcd_import)
    else:
        return module
def __import__ ( name , globals = None , locals = None , fromlist = ( ) , level = 0 ) : if level == 0 : module = _gcd_import ( name ) else : globals_ = globals if globals is not None else { } package = _calc___package__ ( globals_ ) module = _gcd_import ( name , package , level ) if not fromlist : # Return up to the first dot in 'name'. This is complicated by the fact # that 'name' may be relative. if level == 0 : return _gcd_import ( name . partition ( '.' ) [ 0 ] ) elif not name : return module else : # Figure out where to slice the module's name up to the first dot # in 'name'. cut_off = len ( name ) - len ( name . partition ( '.' ) [ 0 ] ) # Slice end needs to be positive to alleviate need to special-case # when ``'.' not in name``. return sys . modules [ module . __name__ [ : len ( module . __name__ ) - cut_off ] ] elif hasattr ( module , '__path__' ) : return _handle_fromlist ( module , fromlist , _gcd_import ) else : return module