-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-40148 Add PurePath.with_stem() #19295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks generally good to me, just one question.
Doc/library/pathlib.rst
Outdated
>>> p.with_stem('final') | ||
PureWindowsPath('c:/Downloads/final.txt') | ||
>>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz') | ||
>>> p.with_name('lib') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely you mean with_stem
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, of course. Thanks. Fixed.
2996ed3
to
327c347
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc/library/pathlib.rst
Outdated
>>> p.with_stem('final') | ||
PureWindowsPath('c:/Downloads/final.txt') | ||
>>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz') | ||
>>> p.with_step('lib') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"stem" not "step"
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
327c347
to
eac93d0
Compare
I have made the requested changes; please review again. |
Thanks for making the requested changes! @pitrou: please review the changes made to this pull request. |
Similar to
PurePath.with_name()
andPurePath.with_suffix()
there should be aPurePath.with_stem()
.A common use case would be appending something before the suffix:
path.with_stem(path.stem + '_v2')
As of now this must be written more cumbersome as:
path.with_name(path.stem + '_v2' + path.suffix)
While the implementation is just a slight modification of
with_name
, I still think it's justified to add this method:with_name()
andsuffix
manually together.https://bugs.python.org/issue40148