On Sat, Feb 22, 2014 at 3:04 PM, Chris Angelico <ros...@gmail.com> wrote: > 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.
I've added a couple of paragraphs to my draft PEP: https://raw.github.com/Rosuav/ExceptExpr/master/pep-0463.txt If someone could please commit that version to the official repo? Or I can submit a diff against the peps repo if that would be easier. 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