Skip to content

Commit 8d4fef4

Browse files
cool-RRmiss-islington
authored andcommitted
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
1 parent d0d9f7c commit 8d4fef4

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
@@ -799,7 +799,11 @@ def name(self):
799799

800800
@property
801801
def suffix(self):
802-
"""The final component's last suffix, if any."""
802+
"""
803+
The final component's last suffix, if any.
804+
805+
This includes the leading period. For example: '.txt'
806+
"""
803807
name = self.name
804808
i = name.rfind('.')
805809
if 0 < i < len(name) - 1:
@@ -809,7 +813,11 @@ def suffix(self):
809813

810814
@property
811815
def suffixes(self):
812-
"""A list of the final component's suffixes, if any."""
816+
"""
817+
A list of the final component's suffixes, if any.
818+
819+
These include the leading periods. For example: ['.tar', '.gz']
820+
"""
813821
name = self.name
814822
if name.endswith('.'):
815823
return []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clarify docstrings of pathlib suffix(es)

0 commit comments

Comments
 (0)