On Sat, Feb 22, 2014 at 1:07 PM, Victor Stinner <victor.stin...@gmail.com> wrote: > At the first read, I'm unable to understand this long expression. At > the second read, I'm still unable to see which instruction will be > executed first: lvl1[key] or lvl2[key]? > > The advantage of the current syntax is that the control flow is > obvious, from the top to the bottom: > > # start > try: > x = lvl1[key] # first instruction > except KeyError: > try: > x = lvl2[key] > except KeyError: > x = f(key) # latest instruction > # end
That's why I'm strongly in favour of syntax variants that have evaluation order be equally obvious: left to right. Its notation may be uglier, but C's ternary operator does get this right, where Python's executes from the inside out. It's not a big deal when most of it is constants, but it can help a lot when the expressions nest. ChrisA _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com