[Python-ideas] except expression

Chris Angelico rosuav at gmail.com
Sun Feb 16 01:57:03 CET 2014


On Sun, Feb 16, 2014 at 11:35 AM, MRAB <python at mrabarnett.plus.com> wrote:
> You'll also need to note that:
>
>
>     ((expr except Exception1: default1) except Exception2: default2)
>
> is not the same as:
>
>     (expr except Exception1: default1 except Exception2: default2)
>
> The first will also catch Exception2 if default1 raises it, whereas the
> second will catch Exception2 only if expr raises it and it hasn't been
> caught by the preceding 'except'.

Ooh. Good catch. This is not just an optimization, it's a specific
piece of syntax: chaining 'except' blocks MUST catch only from the
original.

I'm also switching around my Proposal and Alternative Proposals a bit,
as I'm currently leaning towards the colon rather than a keyword.

Lots of edits to the PEP draft, but so far just kept local to my own
computer. At what point (and in what way) should I start sharing those
edits?

ChrisA


More information about the Python-ideas mailing list