def find_executable(executable, path=None):
 if (path is None):
  path = os.environ['PATH']
 paths = string.split(path, os.pathsep)
 (base, ext) = os.path.splitext(executable)
 if (((sys.platform == 'win32') or (os.name == 'os2')) and (ext != '.exe')):
  executable = (executable + '.exe')
 if (not os.path.isfile(executable)):
  for p in paths:
   f = os.path.join(p, executable)
   if os.path.isfile(f):
    return f
  return None
 else:
  return executable

def find_executable ( executable , path = None ) : if ( path is None ) : path = os . environ [ 'PATH' ] paths = string . split ( path , os . pathsep ) ( base , ext ) = os . path . splitext ( executable ) if ( ( ( sys . platform == 'win32' ) or ( os . name == 'os2' ) ) and ( ext != '.exe' ) ) : executable = ( executable + '.exe' ) if ( not os . path . isfile ( executable ) ) : for p in paths : f = os . path . join ( p , executable ) if os . path . isfile ( f ) : return f return None else : return executable
try to find executable in the directories listed in path .