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 function
returns a default value.
Motivation: mapping an object tree
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
> functi
> 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.
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
> hav
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 PyPI,
> 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 requir
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
Bringing this back on list -- I hope that was an accident.
(NOTE: getting a touch off-topic here -- but I do bring it back around at
the end)
On Wed, May 4, 2022 at 4:38 AM Paul Moore wrote:
> On Tue, 3 May 2022 at 17:46, Christopher Barker
> wrote:
> > On Tue, May 3, 2022 at 5:39 AM Paul Moor
On Wed, 4 May 2022 at 17:04, Christopher Barker wrote:
>
> Bringing this back on list -- I hope that was an accident.
If it was, it was me not spotting that your reply to me was on-list, I
thought you're replied offlist so I followed suit. Not a problem
though, I'm fine with this being on-list (a
On 5/4/2022 1:19 PM, Paul Moore wrote:
Maybe. But really what I want is a way to say "this is what type the
attribute is, but don't assume the init argument is the same type". Or
just not bother with all this at all. This is where it starts to just
become not worth trying to make dataclasses do w
10 matches
Mail list logo