Commit 4a7e25f4 authored by Georg Brandl's avatar Georg Brandl

#444582: fix example and rewrap docs a bit.

parent 4168764c
...@@ -268,31 +268,32 @@ Directory and files operations ...@@ -268,31 +268,32 @@ Directory and files operations
.. versionadded:: 3.3 .. versionadded:: 3.3
.. function:: which(cmd, mode=os.F_OK | os.X_OK, path=None) .. function:: which(cmd, mode=os.F_OK | os.X_OK, path=None)
Return the path to an executable which would be run if the given *cmd* Return the path to an executable which would be run if the given *cmd* was
was called. If no *cmd* would be called, return ``None``. called. If no *cmd* would be called, return ``None``.
*mode* is a permission mask passed a to :func:`os.access`, by default *mode* is a permission mask passed a to :func:`os.access`, by default
determining if the file exists and executable. determining if the file exists and executable.
When no *path* is specified, the results of :func:`os.environ` are When no *path* is specified, the results of :func:`os.environ` are used,
used, returning either the "PATH" value or a fallback of :attr:`os.defpath`. returning either the "PATH" value or a fallback of :attr:`os.defpath`.
On Windows, the current directory is always prepended to the *path* On Windows, the current directory is always prepended to the *path* whether
whether or not you use the default or provide your own, which or not you use the default or provide your own, which is the behavior the
is the behavior the command shell uses when finding executables. command shell uses when finding executables. Additionaly, when finding the
Additionaly, when finding the *cmd* in the *path*, the *cmd* in the *path*, the ``PATHEXT`` environment variable is checked. For
``PATHEXT`` environment variable is checked. For example, if you example, if you call ``shutil.which("python")``, :func:`which` will search
call ``shutil.which("python")``, :func:`which` will search ``PATHEXT`` to know that it should look for ``python.exe`` within the *path*
``PATHEXT`` to know that it should look for ``python.exe`` within directories. For example, on Windows::
the *path* directories.
>>> print(shutil.which("python")) >>> shutil.which("python")
'c:\\python33\\python.exe' 'c:\\python33\\python.exe'
.. versionadded:: 3.3 .. versionadded:: 3.3
.. exception:: Error .. exception:: Error
This exception collects exceptions that are raised during a multi-file This exception collects exceptions that are raised during a multi-file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment