(program)
return None
Return the path for a given executable.
Return the path for a given executable.
Return the path for a given executable .
def which(program):
    """
    Return the path for a given executable.
    """
    def is_exe(file_path):
        """
        Checks whether a file is executable.
        """
        return os.path.isfile(file_path) and os.access(file_path, os.X_OK)

    fpath, _ = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file
    return None
def which ( program ) : def is_exe ( file_path ) : """
        Checks whether a file is executable.
        """ return os . path . isfile ( file_path ) and os . access ( file_path , os . X_OK ) fpath , _ = os . path . split ( program ) if fpath : if is_exe ( program ) : return program else : for path in os . environ [ "PATH" ] . split ( os . pathsep ) : path = path . strip ( '"' ) exe_file = os . path . join ( path , program ) if is_exe ( exe_file ) : return exe_file return None