[Python-ideas] Re: Missing expandvars equivalent in pathlib

2022-02-13 Thread Eryk Sun
On 2/13/22, Eric Fahlgren wrote: > > That may or may not work as Windows has inconsistent treatment of multiple > separators depending on where they appear in a path. If TEMP is a drive > spec, say "t:\", then it expands to "t:\\spam.csv", which is an invalid > windows path. If TEMP is a directo

[Python-ideas] Re: Missing expandvars equivalent in pathlib

2022-02-13 Thread Eryk Sun
On 2/13/22, Paul Moore wrote: > > For better or worse, though, Windows (as an OS) doesn't have a "normal > behaviour". %-expansion is a feature of CMD and .bat files, which You're overlooking ExpandEnvironmentStringsW() [1], ExpandEnvironmentStringsForUserW(), and PathUnExpandEnvStringsW() [2], w

[Python-ideas] Re: Please consider mentioning property without setter when an attribute can't be set

2022-02-13 Thread Eryk Sun
On 2/13/22, Christopher Barker wrote: > > Telling newbies that that means that it's either a property with no setter, > or am object without a __dict__, or one with __slots__ defined is not > really very helpful. The __slots__ case is due to the lack of a __dict__ slot. It can be manually added

[Python-ideas] Re: Please consider mentioning property without setter when an attribute can't be set

2022-02-13 Thread Bruce Leban
I think the more useful message would be something along the lines of AttributeError: can't set attribute 'f' on object of type 'D' This will help you track down the error. Steven D'Aprano listed three reasons why it might fail which sounds right but frequently the underlying reason is so

[Python-ideas] Re: Please consider mentioning property without setter when an attribute can't be set

2022-02-13 Thread Christopher Barker
On Sat, Feb 12, 2022 at 5:32 PM Steven D'Aprano wrote: > > I have to say I agree with Neil here. I was trying to think about what > > other reasons an attribute might be unsettable, and did not quickly come > up > > with that list. > > I'm curious what list you came up with if it excluded the thr

[Python-ideas] Re: Missing expandvars equivalent in pathlib

2022-02-13 Thread Chris Angelico
On Mon, 14 Feb 2022 at 05:15, Eric Fahlgren wrote: > > On Sun, 13 Feb 2022 at 15:43, Chris Angelico wrote: >> >> > it to. If I'm on Windows and I tell something to write to a file in >> > "%TEMP%\spam.csv", then I expect it to understand what that means. >> > Cross-platform support is nice, but t

[Python-ideas] Re: Missing expandvars equivalent in pathlib

2022-02-13 Thread Eric Fahlgren
On Sun, 13 Feb 2022 at 15:43, Chris Angelico wrote: > > it to. If I'm on Windows and I tell something to write to a file in > > "%TEMP%\spam.csv", then I expect it to understand what that means. > > Cross-platform support is nice, but the most common need is for the > > current platform's normal

[Python-ideas] Re: Missing expandvars equivalent in pathlib

2022-02-13 Thread Paul Moore
On Sun, 13 Feb 2022 at 15:43, Chris Angelico wrote: > > Which is why the default should be to follow platform expectations. If > I pass a parameter to a script saying "~/foo/bar", that script should > be able to expanduser/expandvars to make that behave the way I expect > it to. If I'm on Windows

[Python-ideas] Re: Missing expandvars equivalent in pathlib

2022-02-13 Thread Chris Angelico
On Mon, 14 Feb 2022 at 02:34, Paul Moore wrote: > The main point I see of expandvars is to have a way of letting the > *user* pass a string that might reference environment variables, and > expand them. There's some problematic aspects of that already, namely > the platform-dependent handling of %

[Python-ideas] Re: Missing expandvars equivalent in pathlib

2022-02-13 Thread Paul Moore
On Sun, 13 Feb 2022 at 14:26, Stephen J. Turnbull wrote: > > Paul Moore writes: > > > Let's keep it simple. I'm -1 on the request, I don't think expandvars > > should be added to pathlib. > > Would you be happier with a getenv_as_path, so that one could do > > p = Path.getenv_as_path('HOME')

[Python-ideas] Re: Missing expandvars equivalent in pathlib

2022-02-13 Thread Stephen J. Turnbull
Paul Moore writes: > Let's keep it simple. I'm -1 on the request, I don't think expandvars > should be added to pathlib. Would you be happier with a getenv_as_path, so that one could do p = Path.getenv_as_path('HOME') / Path('.python_history') and on my Mac p == Path('/Users/steve/.python

[Python-ideas] Re: Missing expandvars equivalent in pathlib

2022-02-13 Thread Chris Angelico
On Sun, 13 Feb 2022 at 21:47, Paul Moore wrote: > > On Sun, 13 Feb 2022 at 01:09, Steven D'Aprano wrote: > > > I'm sorry Paul, but this sort of made-up, utterly artificial toy example > > adds no benefit to the discussion, it just adds fear, uncertainty and > > doubt to an extremely straight-forw

[Python-ideas] Re: Missing expandvars equivalent in pathlib

2022-02-13 Thread Paul Moore
On Sun, 13 Feb 2022 at 01:09, Steven D'Aprano wrote: > I'm sorry Paul, but this sort of made-up, utterly artificial toy example > adds no benefit to the discussion, it just adds fear, uncertainty and > doubt to an extremely straight-forward feature request. OK, if that's your view then fine. I a