Skip to content

Commit 72b874a

Browse files
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 8d4fef4) Co-authored-by: Ram Rachum <[email protected]>
1 parent 0118d10 commit 72b874a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Lib/pathlib.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,11 @@ def name(self):
797797

798798
@property
799799
def suffix(self):
800-
"""The final component's last suffix, if any."""
800+
"""
801+
The final component's last suffix, if any.
802+
803+
This includes the leading period. For example: '.txt'
804+
"""
801805
name = self.name
802806
i = name.rfind('.')
803807
if 0 < i < len(name) - 1:
@@ -807,7 +811,11 @@ def suffix(self):
807811

808812
@property
809813
def suffixes(self):
810-
"""A list of the final component's suffixes, if any."""
814+
"""
815+
A list of the final component's suffixes, if any.
816+
817+
These include the leading periods. For example: ['.tar', '.gz']
818+
"""
811819
name = self.name
812820
if name.endswith('.'):
813821
return []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clarify docstrings of pathlib suffix(es)

0 commit comments

Comments
 (0)