]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add additional pointers to pathlib's mapping to os.path functions (#94828)
authorChris Adams <chris@improbable.org>
Fri, 15 Jul 2022 22:09:27 +0000 (18:09 -0400)
committerGitHub <noreply@github.com>
Fri, 15 Jul 2022 22:09:27 +0000 (00:09 +0200)
* Add additional pointers to pathlib's mapping to os.path functions

os.path.splitext has a somewhat quirky signature since it mixes the path and filename components but I wanted the documentation to mention `PurePath.stem` as the natural counterpart to `PurePath.suffix` for the common use of `os.path.splitext` to turn "file.py" into "file" and "py".

Technically this could have some discussion of how to handle the parent directory hierarchy but that seems a bit out of keeping with the spirit of this table so I omitted mentioning `PurePath.parents` here.

* Update Doc/library/pathlib.rst

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
Doc/library/pathlib.rst

index 2b798698385fd1e2e915b8cb9ba40b7cc41ce9eb..d5cda3adc8d512149db79e4429f7992a9c793668 100644 (file)
@@ -1300,7 +1300,8 @@ Below is a table mapping various :mod:`os` functions to their corresponding
 :func:`os.path.basename`               :data:`PurePath.name`
 :func:`os.path.dirname`                :data:`PurePath.parent`
 :func:`os.path.samefile`               :meth:`Path.samefile`
-:func:`os.path.splitext`               :data:`PurePath.suffix`
+:func:`os.path.splitext`               :data:`PurePath.stem` and
+                                       :data:`PurePath.suffix`
 ====================================   ==============================
 
 .. rubric:: Footnotes