summaryrefslogtreecommitdiffstats
path: root/Lib/pathlib.py
diff options
context:
space:
mode:
authorRam Rachum <ram@rachum.com>2019-11-02 16:46:24 (GMT)
committerMiss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com>2019-11-02 16:46:24 (GMT)
commit8d4fef4ee2a318097f429cf6cbd4fb2e430bb9da (patch)
treeff35d9acb7b1a8d9c5bd27861f1b610f9f92fd4f /Lib/pathlib.py
parentd0d9f7cfa36bafa4e1d9e73eb08835180d376df1 (diff)
downloadcpython-8d4fef4ee2a318097f429cf6cbd4fb2e430bb9da.zip
cpython-8d4fef4ee2a318097f429cf6cbd4fb2e430bb9da.tar.gz
cpython-8d4fef4ee2a318097f429cf6cbd4fb2e430bb9da.tar.bz2
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
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r--Lib/pathlib.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 825533d..d70fde0 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -799,7 +799,11 @@ class PurePath(object):
@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 @@ class PurePath(object):
@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 []