diff options
author | Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> | 2020-04-19 15:29:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-19 15:29:49 (GMT) |
commit | 8aea4b3605059e243f1827d9328d6fc8d698c0a7 (patch) | |
tree | c77751052337cc6b87f227905c8bb5b447157d2d /Lib/pathlib.py | |
parent | c8f1715283ec51822fb37a702bf253cbac1af276 (diff) | |
download | cpython-8aea4b3605059e243f1827d9328d6fc8d698c0a7.zip cpython-8aea4b3605059e243f1827d9328d6fc8d698c0a7.tar.gz cpython-8aea4b3605059e243f1827d9328d6fc8d698c0a7.tar.bz2 |
bpo-40148: Add PurePath.with_stem() (GH-19295)
Add PurePath.with_stem()
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r-- | Lib/pathlib.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 88ebe03..f98d69e 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -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 |