
On 2/28/2014 4:51 AM, Nick Coghlan wrote:
The preferred notation in the PEP most resembles the existing lambda use case, with "except" instead of "lambda", an exception handling spec instead of an argument list and an additional leading expression:
(expr except Exception: default)
Lots of people don't like the lambda notation though, so it isn't necessarily a particularly compelling parallel to use.
By contrast, it's rare to hear any objections to the {key:value} dict display syntax. Hence the proposed tweak to the syntax to define an "exception handler expression" syntax that is analogous to a dict display rather than a lambda expression:
expr except (Exception: default)
However, I have realised that there*is* a major downside to that notation, which is that it lacks the connotations of lazy evaluation associated with lambda expressions, whereas the default result of an except expression won't be evaluated at all if the exception isn't thrown. You are overlooking that the keyword except provides exactly the connotation of lazy evaluation, so if this is your only reason for
Thank you for explaining why I find the above notation awkward. ": as introducing a suite" never bothered me, because, as you've now enumerated, there are other uses of :. But the lambda syntax parallel is what I don't like about it... I find the lambda syntax hard to read. preferring the lambda syntax, you just erased it :)