[Python-ideas] except expression

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Feb 17 23:38:01 CET 2014


Steven D'Aprano wrote:
> I'm now strongly leaning towards following the lead of generator 
> expressions, and requiring parens around an except-expression.
>
> I think that this will ensure that there is no visual ambiguity when you 
> chain except-expressions.

I think we should keep in mind that we're talking about
what will be a somewhat rarely used construct, and that
the overwhelming majority of those rare uses will be
the simplest possible ones, with just a single 'except'
clause and a very simple expression for the exceptional
case, e.g.

    things[i] except IndexError: None

We should concentrate on making that case as clear and
uncluttered as possible, and not worry overmuch about
how things look in more complicated cases that will
hardly ever arise in practice.

-- 
Greg


More information about the Python-ideas mailing list