[Python-ideas] Null coalescing operators

Sven R. Kunze srkunze at mail.de
Mon Sep 21 18:21:28 CEST 2015

On 21.09.2015 11:05, Andrew Barnert via Python-ideas wrote:
> On Sep 21, 2015, at 01:48, Stephen J. Turnbull <stephen at xemacs.org> wrote:
>>>>>> retries = default else cls.DEFAULT
>> I kinda like this if-less else syntax for the symmetry with else-less
>> if.

That's cool. It reads nice (at least for a non-native speaker). Also 
chaining else reads nice:

final_value = users_value else apps_value else systems_value

> How do you parse this:
>      a if b else c else d
> Feel free to answer either as a human reader or as CPython's LL(1) parser.

Use parentheses if you mix up if-else and else. ;)

Btw. the same applies for: a + b * c + d
If you don't know from you education that b*c would have been evaluated 
first, then it's not obvious either.


More information about the Python-ideas mailing list