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

2022-02-11 Thread Serhiy Storchaka
10.02.22 12:59, anthony.flury via Python-ideas пише: > I know that /os.path/ includes a function /expandvars(..)/ which expands > any environment variables in a given path, but from looking at the > /pathlib/ documentation It seems there is > no equivalent to /os.path.expandvars(..) on any class/ i

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

2022-02-11 Thread Steven D'Aprano
On Thu, Feb 10, 2022 at 02:27:42PM -0800, Neil Girdhar wrote: > AttributeError: can't set attribute 'f' > > This can be a pain to debug when the property is buried in a base class. > Would it make sense to mention the reason why the attribute can't be set, > namely that it's on a property witho

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

2022-02-11 Thread Neil Girdhar
I humbly disagree that any of what you wrote is "obvious". On Fri, Feb 11, 2022 at 4:41 AM Steven D'Aprano wrote: > On Thu, Feb 10, 2022 at 02:27:42PM -0800, Neil Girdhar wrote: > > > AttributeError: can't set attribute 'f' > > > > This can be a pain to debug when the property is buried in a bas

[Python-ideas] Re: Mapping unpacking assignment

2022-02-11 Thread Matsuoka Takuo
I'm sorry for the inaccuracy, and thank you for the corrections! On Fri, 11 Feb 2022 at 01:56, Chris Angelico wrote: > > On Fri, 11 Feb 2022 at 00:33, Matsuoka Takuo wrote: > > .. > > But the crucial thing is to figure out the syntax. Without good > syntax, this is not of interest. > > I'm p

[Python-ideas] Re: Mapping unpacking assignment

2022-02-11 Thread Matsuoka Takuo
On Fri, 11 Feb 2022 at 04:02, Christopher Barker wrote: > > Just one note: > > On Thu, Feb 10, 2022 at 6:56 AM Chris Angelico wrote: >> >> > (2) For the form of the assignment target, I think an analogy with the >> > reception of function arguments could also be considered. > > > I think so -- ma

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

2022-02-11 Thread Christopher Barker
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. And after reading your list, I tried to imagine what I’d tell my beginning students ! But if the error message is indeed unique then y

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

2022-02-11 Thread Christopher Barker
> 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. > > And after reading your list, I tried to imagine what I’d tell my beginning > students ! > > But if the error message is indeed

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

2022-02-11 Thread Christopher Barker
On Fri, Feb 11, 2022 at 12:28 AM Serhiy Storchaka wrote: > expandvars() does not operate on paths, it operates on strings and > bytestrings. There is nothing path-specific here. Expanding environment > variables consists of three distinct steps: > sure -- but it does live in os.paths now, the do

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

2022-02-11 Thread Eric Fahlgren
Yeah, I have to agree with Neil. I had exactly this issue a couple years ago, and it took me an hour or two to figure out that it was a property/descriptor-protocol causing the issue, at which point the fix became trivial. Just knowing to think "it's a property, stupid!" was the hard part and jus

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

2022-02-11 Thread Paul Moore
On Fri, 11 Feb 2022 at 16:37, Christopher Barker wrote: > > On Fri, Feb 11, 2022 at 12:28 AM Serhiy Storchaka wrote: >> >> expandvars() does not operate on paths, it operates on strings and >> bytestrings. There is nothing path-specific here. Expanding environment >> variables consists of three d

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

2022-02-11 Thread Paul Moore
On Fri, 11 Feb 2022 at 18:36, Eric Fahlgren wrote: > > Yeah, I have to agree with Neil. I had exactly this issue a couple years > ago, and it took me an hour or two to figure out that it was a > property/descriptor-protocol causing the issue, at which point the fix became > trivial. Just know

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

2022-02-11 Thread Ricky Teachey
Just had a thought kernel: what if there were an f-string mini-language directive to grab environment variables and expand user paths? That seems to me like it could be even more useful beyond just working with paths. Maybe something like: f"{my_var:$}" This would return the same as os.path.expa

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

2022-02-11 Thread MRAB
On 2022-02-11 20:05, Ricky Teachey wrote: Just had a thought kernel: what if there were an f-string mini-language directive to grab environment variables and expand user paths? That seems to me like it could be even more useful beyond just working with paths. Maybe something like: f"{my_var:

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

2022-02-11 Thread Ricky Teachey
On Fri, Feb 11, 2022 at 4:58 PM MRAB wrote: > On 2022-02-11 20:05, Ricky Teachey wrote: > > Just had a thought kernel: what if there were an f-string mini-language > > directive to grab environment variables and expand user paths? That > > seems to me like it could be even more useful beyond just

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

2022-02-11 Thread Chris Angelico
On Sat, 12 Feb 2022 at 09:34, Ricky Teachey wrote: > > On Fri, Feb 11, 2022 at 4:58 PM MRAB wrote: >> >> On 2022-02-11 20:05, Ricky Teachey wrote: >> > Just had a thought kernel: what if there were an f-string mini-language >> > directive to grab environment variables and expand user paths? That

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

2022-02-11 Thread Ricky Teachey
On Fri, Feb 11, 2022 at 5:44 PM Chris Angelico wrote: > On Sat, 12 Feb 2022 at 09:34, Ricky Teachey wrote: > > > > On Fri, Feb 11, 2022 at 4:58 PM MRAB wrote: > >> > >> On 2022-02-11 20:05, Ricky Teachey wrote: > >> > Just had a thought kernel: what if there were an f-string > mini-language > >

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

2022-02-11 Thread Eryk Sun
On 2/11/22, Paul Moore wrote: > > I'm inclined to say just raise an issue on bpo. If it's easy enough, > it'll just get done. If it's hard, having lots of people support the > idea won't make it any easier. I don't think this is something that > particularly needs evidence of community support bef

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

2022-02-11 Thread Eric V. Smith
On 2/11/2022 5:33 PM, Ricky Teachey wrote: On Fri, Feb 11, 2022 at 4:58 PM MRAB wrote: On 2022-02-11 20:05, Ricky Teachey wrote: > Just had a thought kernel: what if there were an f-string mini-language > directive to grab environment variables and expand user paths? That >

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

2022-02-11 Thread Christopher Barker
you can already put an arbitrary expression in a f-string -- that's the point. So what's wrong with: In [12]: eget = os.environ.get In [13]: f"{eget('HOME')}/bin" Out[13]: '/Users/chris/bin' This seems a rare enough need that special built-in support is not worth it. -CHB On Fri, Feb 11, 20

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

2022-02-11 Thread Steven D'Aprano
On Fri, Feb 11, 2022 at 03:05:47PM -0500, Ricky Teachey wrote: > Just had a thought kernel: what if there were an f-string mini-language > directive to grab environment variables and expand user paths? f-strings make good hammers. Not everything is a nail. -- Steve ___

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

2022-02-11 Thread Steven D'Aprano
On Fri, Feb 11, 2022 at 08:59:57PM -0500, Eric V. Smith wrote: > there are no characters that are invalid format strings, > except '!' and ':'. Thank you for reminding us (including me) of this. -- Steve ___ Python-ideas mailing list -- python-ideas

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

2022-02-11 Thread Steven D'Aprano
On Fri, Feb 11, 2022 at 10:26:03AM +0200, Serhiy Storchaka wrote: > expandvars() does not operate on paths, it operates on strings and > bytestrings. There is nothing path-specific here. Paths can be strings and byte-strings too. When I using my OS shell, and I type: ls -l ~/code/ I am pas