[Python-ideas] except expression

Chris Angelico rosuav at gmail.com
Tue Feb 18 16:07:53 CET 2014


On Wed, Feb 19, 2014 at 1:27 AM, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
> On Tue, Feb 18, 2014 at 9:07 AM, Paul Moore <p.f.moore at gmail.com> wrote:
>>
>> Also, "expr except fallback" is a very simple case of a keyword-based
>> binary operation.
>
>
> I agree and ISTM a natural generalization of this to allow exception type
> specification would be
>
> expr except(Exc1, Exc2) fallback
>
> or
>
> expr except[Exc1, Exc2] fallback
>
> I am not sure if any of these have been proposed, so apologies if they were.

Interestingly, I hadn't read your post when I wrote my own suggestion
of parentheses around the exception type. I'm still not convinced that
it's an improvement over matching the statement form (it still
encourages the bare-except usage, which should be discouraged), but
the fact that two people have come up with this means it can go into
the PEP.

ChrisA


More information about the Python-ideas mailing list