[Python-ideas] if we were to ever shorten `A if A else B` (was: PEP 505: None-aware operators)

Grégory Lielens gregory.lielens at gmail.com
Sat Jul 21 15:29:33 EDT 2018


Coming from the @ side (I was strong +1 on this), I have troubles seeing the real benefits from ?? (And even more from associates): did we really have long and complex expressions where the compactness of an operator would help? 

Operators are inherently obscure (except for those that are learnt in elementary school), but they help when you combine multiple operators and benefit from their precedence rules. There you can benefit from them, even if explicit it's better than implicit...
It was the case for @, and even with proofs of long formulas, and a history of matrix algebra from hundreds of years before computing science, the resistance was strong: a majority of non-numpy users resisted it, saying a function matmul(A,B) was good enough and A at B would bring nothing.
It was eventually accepted, 7 or so years after the initial proposal, through another PEP, when relative weight of numpy community was probably larger.
So i'd like to see examples of long expressions that would really benefit groin using an very specific operator. At this point, the explicitness of "a if a is not None else []" wins, by a long shot...


More information about the Python-ideas mailing list