[Python-checkins] Add additional pointers to pathlib's mapping to os.path functions (GH-94828)

miss-islington webhook-mailer at python.org
Fri Jul 15 18:21:39 EDT 2022


https://github.com/python/cpython/commit/734c8b7e55e37883af738198dc52fbf5011962c6
commit: 734c8b7e55e37883af738198dc52fbf5011962c6
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-07-15T15:21:34-07:00
summary:

Add additional pointers to pathlib's mapping to os.path functions (GH-94828)


* 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 at gmail.com>

Co-authored-by: Ezio Melotti <ezio.melotti at gmail.com>
(cherry picked from commit 3789c635772fbdeb5d0fc32aa811fd6b1d935a60)

Co-authored-by: Chris Adams <chris at improbable.org>

files:
M Doc/library/pathlib.rst

diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index c4fe645e3c903..5012150b86cef 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -1319,7 +1319,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



More information about the Python-checkins mailing list