Skip to content

Commit 0d38409

Browse files
authored
Doc: Improve documentation for the path argument in shutil.which() (#124494)
1 parent 54dd77f commit 0d38409

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Doc/library/shutil.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,10 @@ Directory and files operations
449449
*mode* is a permission mask passed to :func:`os.access`, by default
450450
determining if the file exists and is executable.
451451

452-
*path* is a "``PATH`` string" specifying the lookup directory list. When no
453-
*path* is specified, the results of :func:`os.environ` are used, returning
454-
either the "PATH" value or a fallback of :data:`os.defpath`.
452+
*path* is a "``PATH`` string" specifying the directories to look in,
453+
delimited by :data:`os.pathsep`. When no *path* is specified, the
454+
:envvar:`PATH` environment variable is read from :data:`os.environ`,
455+
falling back to :data:`os.defpath` if it is not set.
455456

456457
On Windows, the current directory is prepended to the *path* if *mode* does
457458
not include ``os.X_OK``. When the *mode* does include ``os.X_OK``, the
@@ -460,9 +461,9 @@ Directory and files operations
460461
consulting the current working directory for executables: set the environment
461462
variable ``NoDefaultCurrentDirectoryInExePath``.
462463

463-
Also on Windows, the ``PATHEXT`` variable is used to resolve commands
464-
that may not already include an extension. For example, if you call
465-
``shutil.which("python")``, :func:`which` will search ``PATHEXT``
464+
Also on Windows, the :envvar:`PATHEXT` environment variable is used to
465+
resolve commands that may not already include an extension. For example,
466+
if you call ``shutil.which("python")``, :func:`which` will search ``PATHEXT``
466467
to know that it should look for ``python.exe`` within the *path*
467468
directories. For example, on Windows::
468469

0 commit comments

Comments
 (0)