> On 3 Oct 2021, at 18:37, Steven D'Aprano <st...@pearwood.info> wrote: > > On Sun, Oct 03, 2021 at 04:47:57PM +0100, Irit Katriel via Python-Dev wrote: >> We wonder if people have a view on which of the following is clearer/better: >> >> 1. except *E as e: // except *(E1, E2) as e: > > That looks like you're unpacking the tuple (E1, E2), and that's just > misleading and wrong.
Interestingly, IIRC this was the original intention: `except *E as e` means you're unpacking E from some group. I agree this is a somewhat convoluted analogy and it breaks down in the presence of a tuple of exception names. >> 2. except* E as e: // except* (E1, E2) as e: > > But Thomas Grainger's comment about match semantics got me thinking. Uh oh ;-) > I think his suggestion is a bit too verbose, but how do people feel about > borrowing the vertical line and using it like this: > > except| E as e: > except| (E1, E2) as e: -1 If I could read the vertical line as a pipe character, the expression would read "except or E as e". But I can't read it that way anyway. Instead, all I see is a lowercase EXCEPTL. My idea is this: try: ... except group E as e: ... except group E1, T2 as e: ... Should be doable given the magical match-case contextual keywords precedent. This looks nice and is explicit, since you will always get an ExceptionGroup instance under `e`. But I know it's a bit late for bikeshedding this thing so if we want to be conservative and stick to the current syntactical options already defined in PEP 654, I'm voting Option 2 (given the awkwardness of the *(E1, E2) example). - Ł
signature.asc
Description: Message signed with OpenPGP
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/T7QZJ575RFNYZ5KMYD66YMR2ZLNDVF56/ Code of Conduct: http://python.org/psf/codeofconduct/