From 71abd1d4d5f068c9a9346cee966be08523086514 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Wed, 9 Oct 2019 18:12:46 +0300 Subject: [PATCH] bpo-38422: Clarify docstrings of pathlib suffix(es) --- Lib/pathlib.py | 12 ++++++++++-- .../Library/2019-10-09-18-16-51.bpo-38422.aiM5bq.rst | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2019-10-09-18-16-51.bpo-38422.aiM5bq.rst diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 7bd66c10cbdb64..66bef291ab0932 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -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: @@ -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 [] diff --git a/Misc/NEWS.d/next/Library/2019-10-09-18-16-51.bpo-38422.aiM5bq.rst b/Misc/NEWS.d/next/Library/2019-10-09-18-16-51.bpo-38422.aiM5bq.rst new file mode 100644 index 00000000000000..0958fe265db560 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-10-09-18-16-51.bpo-38422.aiM5bq.rst @@ -0,0 +1 @@ +Clarify docstrings of pathlib suffix(es)