[Python-checkins] bpo-38422: Clarify docstrings of pathlib suffix(es) (GH-16679)

Miss Skeleton (bot) webhook-mailer at python.org
Sat Nov 2 12:47:00 EDT 2019


https://github.com/python/cpython/commit/8d4fef4ee2a318097f429cf6cbd4fb2e430bb9da
commit: 8d4fef4ee2a318097f429cf6cbd4fb2e430bb9da
branch: master
author: Ram Rachum <ram at rachum.com>
committer: Miss Skeleton (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2019-11-02T09:46:24-07:00
summary:

bpo-38422: Clarify docstrings of pathlib suffix(es) (GH-16679)



Whenever I use `path.suffix` I have to check again whether it includes the dot or not. I decided to add it to the docstring so I won't have to keep checking. 


https://bugs.python.org/issue38422



Automerge-Triggered-By: @pitrou

files:
A Misc/NEWS.d/next/Library/2019-10-09-18-16-51.bpo-38422.aiM5bq.rst
M Lib/pathlib.py

diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 825533d8d5f97..d70fde0ea3b45 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -799,7 +799,11 @@ def name(self):
 
     @property
     def suffix(self):
-        """The final component's last suffix, if any."""
+        """
+        The final component's last suffix, if any.
+
+        This includes the leading period. For example: '.txt'
+        """
         name = self.name
         i = name.rfind('.')
         if 0 < i < len(name) - 1:
@@ -809,7 +813,11 @@ def suffix(self):
 
     @property
     def suffixes(self):
-        """A list of the final component's suffixes, if any."""
+        """
+        A list of the final component's suffixes, if any.
+
+        These include the leading periods. For example: ['.tar', '.gz']
+        """
         name = self.name
         if name.endswith('.'):
             return []
diff --git a/Misc/NEWS.d/next/Library/2019-10-09-18-16-51.bpo-38422.aiM5bq.rst b/Misc/NEWS.d/next/Library/2019-10-09-18-16-51.bpo-38422.aiM5bq.rst
new file mode 100644
index 0000000000000..0958fe265db56
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-10-09-18-16-51.bpo-38422.aiM5bq.rst
@@ -0,0 +1 @@
+Clarify docstrings of pathlib suffix(es)



More information about the Python-checkins mailing list