mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-40148: Add PurePath.with_stem() (GH-19295)
Add PurePath.with_stem()
This commit is contained in:
parent
c8f1715283
commit
8aea4b3605
4 changed files with 60 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue