def run_path(path_name, init_globals=None, run_name=None):
 if (run_name is None):
  run_name = '<run_path>'
 importer = _get_importer(path_name)
 if isinstance(importer, imp.NullImporter):
  code = _get_code_from_file(path_name)
  return _run_module_code(code, init_globals, run_name, path_name)
 else:
  sys.path.insert(0, path_name)
  try:
   main_name = '__main__'
   saved_main = sys.modules[main_name]
   del sys.modules[main_name]
   try:
    (mod_name, loader, code, fname) = _get_main_module_details()
   finally:
    sys.modules[main_name] = saved_main
   pkg_name = ''
   with _TempModule(run_name) as temp_module:
    with _ModifiedArgv0(path_name):
     mod_globals = temp_module.module.__dict__
     return _run_code(code, mod_globals, init_globals, run_name, fname, loader, pkg_name).copy()
  finally:
   try:
    sys.path.remove(path_name)
   except ValueError:
    pass

def run_path ( path_name , init_globals = None , run_name = None ) : if ( run_name is None ) : run_name = '<run_path>' importer = _get_importer ( path_name ) if isinstance ( importer , imp . NullImporter ) : code = _get_code_from_file ( path_name ) return _run_module_code ( code , init_globals , run_name , path_name ) else : sys . path . insert ( 0 , path_name ) try : main_name = '__main__' saved_main = sys . modules [ main_name ] del sys . modules [ main_name ] try : ( mod_name , loader , code , fname ) = _get_main_module_details ( ) finally : sys . modules [ main_name ] = saved_main pkg_name = '' with _TempModule ( run_name ) as temp_module : with _ModifiedArgv0 ( path_name ) : mod_globals = temp_module . module . __dict__ return _run_code ( code , mod_globals , init_globals , run_name , fname , loader , pkg_name ) . copy ( ) finally : try : sys . path . remove ( path_name ) except ValueError : pass
execute code located at the specified filesystem location returns the resulting top level namespace dictionary the file path may refer directly to a python script or else it may refer to a zipfile or directory containing a top level __main__ .