![](https://secure.gravatar.com/avatar/f3ba3ecffd20251d73749afbfa636786.jpg?s=120&d=mm&r=g)
On 22 February 2014 00:44, Eli Bendersky <eliben@gmail.com> wrote:
True, but at least you still have to explicitly try...except... which takes a toll on the code so isn't taken lightly. Adding except into expressions, I fear, will proliferate this usage much more.
The same fears were raised regarding conditional expressions, and they'll be dealt with the same way: style guides and code review. That's also why the examples part of the PEP is so important, though: this is about providing a tool to *improve* readability in the cases where it applies, without significantly increasing the cognitive burden of the language. One example not mentioned in the PEP is that "text.find(substr)" would become just a shorthand for "text.index(substr) except ValueError: -1", but the latter has the benefit that you can substitute "None" instead, which avoids the trap where "-1" is a valid subscript for the string (but doesn't give you the answer you want). Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia