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
This commit is contained in:
parent
d0d9f7cfa3
commit
8d4fef4ee2
|
@ -799,7 +799,11 @@ class PurePath(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def suffix(self):
|
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
|
name = self.name
|
||||||
i = name.rfind('.')
|
i = name.rfind('.')
|
||||||
if 0 < i < len(name) - 1:
|
if 0 < i < len(name) - 1:
|
||||||
|
@ -809,7 +813,11 @@ class PurePath(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def suffixes(self):
|
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
|
name = self.name
|
||||||
if name.endswith('.'):
|
if name.endswith('.'):
|
||||||
return []
|
return []
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Clarify docstrings of pathlib suffix(es)
|
Loading…
Reference in New Issue