bpo-40148: Add PurePath.with_stem() (GH-19295)

Add PurePath.with_stem()
This commit is contained in:
Tim Hoffmann 2020-04-19 17:29:49 +02:00 committed by GitHub
parent c8f1715283
commit 8aea4b3605
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 0 deletions

View file

@ -870,6 +870,10 @@ class PurePath(object):
return self._from_parsed_parts(self._drv, self._root,
self._parts[:-1] + [name])
def with_stem(self, stem):
"""Return a new path with the stem changed."""
return self.with_name(stem + self.suffix)
def with_suffix(self, suffix):
"""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