Skip to content

bpo-38422: Clarify docstrings of pathlib suffix(es) #16679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,11 @@ def name(self):

@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:
Expand All @@ -805,7 +809,11 @@ def suffix(self):

@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 []
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarify docstrings of pathlib suffix(es)