On Tue, 29 Oct 2019 at 15:29, Ricky Teachey <ri...@teachey.org> wrote:
>
> There are already .with_suffix() and with_name() methods. Including 
> with_stem() seems obvious, no?

As you say, it's a minor thing (either way) but I've never had the
need for a `with_stem` method. Do you have a real-life use case (as
opposed to just wanting it for completeness)?

Having  a real example would help decide the appropriate behaviour for
corner cases like x.with_stem('name.ext'). Your two suggested
equivalents behave differently in that case:

>>> old_path = Path(r"C:\x.txt")
>>> old_path.with_name("y.xxx" + old_path.suffix)
WindowsPath('C:/y.xxx.txt')
>>> old_path.with_name("y.xxx").with_suffix(old_path.suffix)
WindowsPath('C:/y.txt')
_______________________________________________
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/WSKMYQLOCGU63BDN62ZSZOONHDKEMGWF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to