[Python-ideas] except expression

Chris Angelico rosuav at gmail.com
Thu Feb 20 05:14:13 CET 2014


On Thu, Feb 20, 2014 at 1:58 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Another idea:
>
>    things[i] or else None if IndexError
>
> You can't claim that the exception is in the wrong place
> in relation to the 'except' keyword, because there is no
> 'except' keyword!

Added to the Alternative Proposals section for completeness, but I
don't particularly like this. It uses three keywords which currently
all occur in expression contexts; whether the parser can handle it or
not, I suspect there'll be a lot of odd cases where a human has
trouble reading it.

ChrisA


More information about the Python-ideas mailing list