mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-34329: Doc'd how to remove suffix of pathlib.Path() (GH-8655)
This commit is contained in:
parent
5a953fd0ab
commit
46dc4e34ed
2 changed files with 9 additions and 3 deletions
|
@ -807,8 +807,10 @@ class PurePath(object):
|
|||
self._parts[:-1] + [name])
|
||||
|
||||
def with_suffix(self, suffix):
|
||||
"""Return a new path with the file suffix changed (or added, if none)."""
|
||||
# XXX if suffix is None, should the current suffix be removed?
|
||||
"""Return a new path with the file suffix changed. If the path
|
||||
has no suffix, add given suffix. If the given suffix is an empty
|
||||
string, remove the suffix from the path.
|
||||
"""
|
||||
f = self._flavour
|
||||
if f.sep in suffix or f.altsep and f.altsep in suffix:
|
||||
raise ValueError("Invalid suffix %r" % (suffix))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue