> Seems like the right implementation to me. Does anybody disagree that a
>> bug report with a PR is the way to move forward on this?
>>
>
> Depends if you're okay with the PR potentially being rejected because the
> idea gets rejected. If you're fine with that then do both, if you're not
> then I
On Tue, Oct 29, 2019 at 12:29 PM Ricky Teachey wrote:
> 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
>
> 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
On 10/29/2019 10:41 AM, Paul Moore wrote:
On Tue, 29 Oct 2019 at 17:38, Ethan Furman wrote:
On 10/29/2019 10:17 AM, Brian Skinn 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
On Tue, 29 Oct 2019 at 17:38, Ethan Furman wrote:
>
> On 10/29/2019 10:17 AM, Brian Skinn 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.
>
> It does
On Tue, 29 Oct 2019 at 17:08, Andrew Barnert 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
> 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
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.
I.e., it should be:
p = Path("foo.bar.txt")
p.with_stem("quux")
"quux.txt"
p.with_stem("baz.quux")
"baz.quux.txt"
On Oct 29, 2019, at 09:05, Paul Moore wrote:
>
> Having a real example would help decide the appropriate behaviour for
> corner cases like x.with_stem('name.ext').
I just realized that my use case doesn’t help answer your corner case.
Hopefully the OP’s will have one. But I can imagine one
On Oct 29, 2019, at 09:05, Paul Moore wrote:
>
> 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)?
I have a real-life use case, which I’ll simplify here:
def safe_create(path):
try:
return
On Tue, 29 Oct 2019 at 15:29, Ricky Teachey 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
Correction; I intended to use with_suffix() for the second example:
>>> old_path = Path(r"C:\x.txt")
>>> old_path.with_name("y").with_suffix(old_path.suffix)
WindowsPath('C:/y.txt')
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe
12 matches
Mail list logo