def discover_executable(name, sitepath):
 paths = ([str(sitepath)] + os.environ['PATH'].split(os.pathsep))
 for path in paths:
  full_name = os.path.join(path, name)
  if os.path.exists(full_name):
   return full_name
 return None

def discover_executable ( name , sitepath ) : paths = ( [ str ( sitepath ) ] + os . environ [ 'PATH' ] . split ( os . pathsep ) ) for path in paths : full_name = os . path . join ( path , name ) if os . path . exists ( full_name ) : return full_name return None
finds an executable in the given sitepath or in the path list provided by the path environment variable .