On this page
  1. shutil.which
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

shutil.which

Prev: shutil.unregister_unpack_format | Up: shutil
Rel: shutil.chown, shutil.copy, shutil.copy2, shutil.copyfile
Ref: docs.python.org — shutil.which
Tags: #public #python3 #stdlib #shutil


Import

import shutil
from shutil import which

Signature & Overview

shutil.which(cmd, mode=1, path=None)

Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file.

Usage

import shutil

py = shutil.which("python3")
assert py is None or isinstance(py, str)

Gotchas

REPL Inspect

from shutil import which
help(which)

Linked from

Related notes