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 8d4fef4ee2)

Co-authored-by: Ram Rachum <ram@rachum.com>
This commit is contained in:
Miss Skeleton (bot) 2019-11-02 10:04:18 -07:00 committed by GitHub
parent 0118d109d5
commit 72b874a2ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -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 []

View File

@ -0,0 +1 @@
Clarify docstrings of pathlib suffix(es)