(program)
return None
Find the path of an executable
Find the path of an executable
Find the path of an executable
def which(program):
    """ Find the path of an executable """
    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, 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):
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file

    return None
def which ( program ) : def is_exe ( fpath ) : return os . path . isfile ( fpath ) and os . access ( fpath , 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 ) : exe_file = os . path . join ( path , program ) if is_exe ( exe_file ) : return exe_file return None