On Tue, 29 Oct 2019 at 17:08, Andrew Barnert <abarn...@yahoo.com> wrote: > > If you wanted my safe_create function to do Mac-like “copy 3 of > spam.eggs.txt” instead of Windows-style “spam.eggs (3).txt”, then you would > end up calling path.with_stem("copy 3 of spam.eggs"), and you would > definitely want the ".eggs" to be added to rather than replaced. So, the OP’s > first implementation would be the right one, not his second.
On Tue, 29 Oct 2019 at 17:19, Brian Skinn <brian.sk...@gmail.com> wrote: > > I feel like the semantics of PurePath.suffix > (https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.suffix) and > PurePath.stem define this pretty unambiguously. [...] > p.with_stem("baz.quux") > "baz.quux.txt" Cool. Sounds like def with_stem(self, new_stem): self.with_name(new_stem + self.suffix) is the preferred solution. I agree it seems like the right option. As I said, I don't think it's a big deal either way. A bugs.python.org issue with an attached PR implementing (and documenting) this seems like the way to go - no big need to debate it. Although it's good that we caught the difference in behaviour between the two options - any patch adding this should include tests for this particular corner case (and any others that you can think of ;-)) Paul _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/PAFEC4GSSE4JVI5BCP754IFPNIGEAPTG/ Code of Conduct: http://python.org/psf/codeofconduct/