Which
which(name, all=False)
¶
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 :const:True
the set of all found locations is returned, else the first occurrence or :const:None
is returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
`name` | str | The file to search for. | required |
`all` | bool | Whether to return all locations where | required |
Returns:
Type | Description |
---|---|
Set[str] | str | None | If |
Set[str] | str | None | else the first location or :const: |
Example
which('sh') '/bin/sh'