[Python-ideas] Re: Get the value of an attribute of an object hierarchy with a path expression

2022-05-05 Thread Greg Ewing
On 5/05/22 3:53 am, gabor.g...@proinbox.com wrote: I think it is pretty frequent to check that a variable is not None before accessing it's attributes or element. While that's probably true, in my experience I'm usually performing the test once on a particular object and then accessing a

[Python-ideas] Re: Get the value of an attribute of an object hierarchy with a path expression

2022-05-04 Thread gabor . guta
1) How frequently do people write (some version of) this function? I think it is pretty frequent to check that a variable is not None before accessing it's attributes or element. 1a) Can all variants of the function be cleanly provided by a single stdlib function? 2 functions can reasonably cover

[Python-ideas] Re: Get the value of an attribute of an object hierarchy with a path expression

2022-05-04 Thread Dr . Guta Gábor
> Well, there are at least two libraries on PyPI, and at least one of > them (glom) has been around for some time, but neither is particularly > well known. This suggests to me that this isn't an issue that people > are routinely asking "how do I solve this problem?" (or if they are, > their

[Python-ideas] Re: Get the value of an attribute of an object hierarchy with a path expression

2022-05-04 Thread Paul Moore
On Wed, 4 May 2022 at 13:29, Dr. Guta Gábor wrote: > > > I'm not sure there's enough need for this that it should be in the > > stdlib. And I'm certain it isn't sufficiently common to justify being > > a builtin. > How 'enough need' can be measured? Well, there are at least two libraries on

[Python-ideas] Re: Get the value of an attribute of an object hierarchy with a path expression

2022-05-04 Thread Chris Angelico
On Wed, 4 May 2022 at 22:32, Dr. Guta Gábor wrote: > > > I'm not sure there's enough need for this that it should be in the > > stdlib. And I'm certain it isn't sufficiently common to justify being > > a builtin. > How 'enough need' can be measured? The other way to solve this problem is to >

[Python-ideas] Re: Get the value of an attribute of an object hierarchy with a path expression

2022-05-04 Thread Dr . Guta Gábor
> I'm not sure there's enough need for this that it should be in the > stdlib. And I'm certain it isn't sufficiently common to justify being > a builtin. How 'enough need' can be measured? The other way to solve this problem is to have null-conditional access operators ?. and ?[] like in C# (i.e.

[Python-ideas] Re: Get the value of an attribute of an object hierarchy with a path expression

2022-05-04 Thread Paul Moore
On Wed, 4 May 2022 at 12:27, Dr. Guta Gábor wrote: > > This proposal is about adding a builtin function or a package to the standard > library to access an element in an object hierarchy with default behavior > i.e. if at any level the attribute/key/index does not exist in the path the >