Terry Reedy <tjre...@udel.edu>: > On 8/17/2016 2:39 AM, Steven D'Aprano wrote: > "If I finish work on on time, go to the movies, otherwise just go home." > is also real English syntax, and to me, more graceful. It is certainly > more neutral among the alternatives. The inverted version implies a > clear preference for the first alternative. > > It would be an interesting exercise to see which order for ternary > expressions is more common in some large corpus of English text.
Python's ternary expression has a distinct Perl flavor to it. However, the problem with the "then" keyword was valid. Also, Python's comprehensions already had a postfix "if". Personally, I'd normally steer clear of ternary conditionals both in C and Python. This reminds me of a discussion I had yesterday about why Scheme can't implement a proper try/finally construct. That's because Scheme supports continuations; nothing is really final. Python would gain a similar power if there were a way to cancel exceptions: try: do_something() except ValueError: retry 123 where: def do_something(): def_value = raise ValueError a += def_value What Python would then need is a try/nevermind: resource = grab_it() while True: try: resource.operate() finally: resource.release() break nevermind: resource.take_back() Marko -- https://mail.python.org/mailman/listinfo/python-list