(mod_name, init_globals=None,
               run_name=None, alter_sys=False)
Execute a module's code without importing it

       Returns the resulting top level namespace dictionary
Execute a module's code without importing it
Execute a module s code without importing it
def run_module(mod_name, init_globals=None,
               run_name=None, alter_sys=False):
    """Execute a module's code without importing it

       Returns the resulting top level namespace dictionary
    """
    mod_name, mod_spec, code = _get_module_details(mod_name)
    if run_name is None:
        run_name = mod_name
    if alter_sys:
        return _run_module_code(code, init_globals, run_name, mod_spec)
    else:
        # Leave the sys module alone
        return _run_code(code, {}, init_globals, run_name, mod_spec)
def run_module ( mod_name , init_globals = None , run_name = None , alter_sys = False ) : mod_name , mod_spec , code = _get_module_details ( mod_name ) if run_name is None : run_name = mod_name if alter_sys : return _run_module_code ( code , init_globals , run_name , mod_spec ) else : # Leave the sys module alone return _run_code ( code , { } , init_globals , run_name , mod_spec )