[Python-ideas] A better (simpler) approach to PEP 505

Grégory Lielens gregory.lielens at gmail.com
Mon Jul 23 13:53:11 EDT 2018


The proto here swallow and short circuit on attribute error. Changing to do it on Noneness is easy, and you can choose between the two behavior: it's a strength compared to the operator approach.

It's working in current python, another strength.

I think short-circuit behavior is similar: once stopping condition has been met, the gard object cascade till the end of the nested attribute lookup. Like None do for the operator.

More complex stuff when None-coalescing attribute access is mixed with normal access is better done with operators.
Maybe complex operations fine of the middle of the access chain would also be easier with the operators.

How many times would you encounter that in real cases? I bet on very few.
In those few case, would a one line ?. chain expression be better than a multiple line logic with temporaries? I think no.

That's my feeling, but in the absence of concrete examples, feelings are ok.


More information about the Python-ideas mailing list