Skip to content

which ¤

Functions:

  • which

    which(name, flags = os.X_OK, all = False) -> str or str set

which ¤

which(name: str, all: bool = False) -> str | set[str] | None

which(name, flags = os.X_OK, all = False) -> str or str set

Works as the system command which; searches $PATH for name and returns a full path if found.

If all is True the set of all found locations is returned, else the first occurrence or None is returned.

Parameters:

  • name (str) –

    The file to search for.

  • all (bool, default: False ) –

    Whether to return all locations where name was found.

Returns:

  • str | set[str] | None

    If all is True the set of all locations where name was found,

  • str | set[str] | None

    else the first location or None if not found.

Example

which('sh') '/bin/sh'