summaryrefslogtreecommitdiffstats
path: root/Lib/pathlib.py
diff options
context:
space:
mode:
authorMiss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com>2019-11-02 17:04:18 (GMT)
committerGitHub <noreply@github.com>2019-11-02 17:04:18 (GMT)
commit72b874a2ac6a7c1931e8b60fb865dc57adb441ee (patch)
tree98d7e0c70ace749429d97c1bc7fb99c90300494d /Lib/pathlib.py
parent0118d109d54bf75c99a8b0fa9aeae1a478ac4b7e (diff)
downloadcpython-72b874a2ac6a7c1931e8b60fb865dc57adb441ee.zip
cpython-72b874a2ac6a7c1931e8b60fb865dc57adb441ee.tar.gz
cpython-72b874a2ac6a7c1931e8b60fb865dc57adb441ee.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 (cherry picked from commit 8d4fef4ee2a318097f429cf6cbd4fb2e430bb9da) Co-authored-by: Ram Rachum <ram@rachum.com>
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 af9747b..d868254 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -797,7 +797,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:
@@ -807,7 +811,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 []