which ¤
Functions:
-
which–which(name, flags = os.X_OK, all = False) -> str or str set
which ¤
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
namewas found.
Returns:
-
str | set[str] | None–If
allisTruethe set of all locations wherenamewas found, -
str | set[str] | None–else the first location or
Noneif not found.
Example
which('sh') '/bin/sh'