[Python-ideas] PEP 505: None-aware operators

Rhodri James rhodri at kynesim.co.uk
Tue Jul 24 07:37:35 EDT 2018


On 24/07/18 12:02, David Mertz wrote:
> Every use I've suggested for the magic proxy is similar to:
> 
>    NullCoalesce(cfg).user.profile.food
> 
> Yes, the class is magic. That much more so in the library I published last
> night that utilizes wrapt.ObjectProxy. But it's also pretty explicit in
> that an actual*word*  announces that funny stuff is going to happen on the
> same line.

      Foo(cfg).user.profile.food

Is that explicit that funny stuff is going to happen on the same line? 
I wouldn't generally assume so, I'd just assume the coder created a 
throwaway object to get at an attribute.  You have to know that 
"NullCoalesce" does magic before it is at all explicit that funny stuff 
will happen.  Thinking about it, NullCoalesce() may be *less* explicit 
than ?. because at least that doesn't look like ordinary attribute 
reference.

I'm still of the opinion that both approaches are trying to solve a 
problem that's too niche to merit them, BTW.

-- 
Rhodri James *-* Kynesim Ltd


More information about the Python-ideas mailing list