1. except *E as e: // except *(E1, E2) as e:2. except* E as e: // except* (E1, E2) as e:
_______________________________________________
Python-Dev mailing list -- pytho...@python.org
To unsubscribe send an email to python-d...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/pytho...@python.org/message/4B256YKUPW5P2M44GG5H6FBL3PSV6ODP/
Code of Conduct: http://python.org/psf/codeofconduct/
Code of Conduct: http://python.org/psf/codeofconduct/
We can drop except. Say:
try:
..
handle T1:
…
handle T2:
…
Or ‘catch’, or something else.
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).
- Ł
_______________________________________________
Python-Dev mailing list -- pytho...@python.org
To unsubscribe send an email to python-d...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
On Sun, Oct 03, 2021 at 11:34:55AM -0700, Guido van Rossum wrote:
> I also think that the bar should be pretty high before we reopen the
> *syntax* -- the PEP was approved without anyone (neither the SC, nor
> Nathaniel, nor anyone else) providing any feedback on the use of 'except
> *'. So I think it's a bit late to be bikeshedding the syntax. This thread
> was meant to solicit feedback on how to *format* it: does the space go
> before or after the '*'.
`except* E`, otherwise it looks like unpacking E.
Therefore my vote is for requiring `except* E` and keeping `except *E` as a SyntaxError.
_______________________________________________
Python-Dev mailing list -- pytho...@python.org
To unsubscribe send an email to python-d...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/pytho...@python.org/message/F2JUI7SWTQE6RJ4YYKQHJ233BERZHYWR/
_______________________________________________
Python-Dev mailing list -- pytho...@python.org
To unsubscribe send an email to python-d...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Code of Conduct: http://python.org/psf/codeofconduct/
On 4 Oct 2021, at 15:00, Calvin Spealman <cspe...@redhat.com> wrote:It is difficult to understand why any special syntax is needed at all. ExceptionGroup is still an exception class like any other, isn't it? Why wouldn't the existing syntax suffice?
On Sun, Oct 3, 2021 at 9:20 PM Jonathan Goble <jcgo...@gmail.com> wrote:Therefore my vote is for requiring `except* E` and keeping `except *E` as a SyntaxError.You can't do that with our current lexer+parser.
The question was about which style to *recommend* (a la PEP-8).
_______________________________________________
Python-Dev mailing list -- pytho...@python.org
To unsubscribe send an email to python-d...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Code of Conduct: http://python.org/psf/codeofconduct/
On Sun, Oct 3, 2021 at 9:20 PM Jonathan Goble <jcgo...@gmail.com> wrote:
Therefore my vote is for requiring `except* E` and keeping `except *E` as a SyntaxError.
You can't do that with our current lexer+parser.
On Mon, 4 Oct 2021 12:18:35 -0400
Calvin Spealman <cspe...@redhat.com> wrote:
> On Mon, Oct 4, 2021 at 12:07 PM Guido van Rossum <gu...@python.org> wrote:
>
> > The question was about which style to *recommend* (a la PEP-8).
> >
>
> I think the very fact that it can't (or is difficult) be enforced,
How so? If style checkers are already able to check whitespace around
operators, they should be to check whitespace in this instance as well.
Do you suggest that PEP 8 violations should be detected by the Python
parser itself?
Python-Dev mailing list -- pytho...@python.org
To unsubscribe send an email to python-d...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/pytho...@python.org/message/ZLU5NYXVRCUM7AEEN55ITUQO43VDY6RE/
Code of Conduct: http://python.org/psf/codeofconduct/
On Oct 3, 2021, at 10:42, Łukasz Langa <luk...@langa.pl> wrote:Speaking just for myself, the `except *` syntax always bothered me, but I couldn’t come up with anything better and it wasn’t enough for me to vote against PEP 654. `except group` is nicer though, and I would be in favor of that, or something like it.
We could of course bike shed on the syntax forever. The PSC did vote to accept the PEP but we left room for changes while during the 3.11 cycle. -Barry
_______________________________________________ Python-Dev mailing list -- pytho...@python.org To unsubscribe send an email to python-d...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/pytho...@python.org/message/7KHAN76UA5JRND2M2EMVLKML665KQDTC/
1. except *E as e: // except *(E1, E2) as e:
2. except* E as e: // except* (E1, E2) as e:
I vote #2, because `except *(e1, e2) as e:` could imply that this is splatting an arbitrary expression there - it looks like it will match any number of dynamically chosen exception types.
What about `except case ExceptionGroup[E1 | E2]:`? and use match semantics?
On Sun, 3 Oct 2021, 16:50 Irit Katriel via Python-Dev, <pytho...@python.org> 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:
2. except* E as e: // except* (E1, E2) as e:
(The difference is in the whitespace around the *).
At the moment * is a separate token so both are allowed, but we could change that (e.g., make except* a token), and in any case we need to settle on a convention that we use in documentation, etc.
It is also not too late to opt for a completely different syntax if a better one is suggested.
I don't think X[Y | Z] is close to any syntax match currently allows.
But... I have long thought that the interpreter's exception
matching abilities were underused by the language. Maybe this is
an opportunity for something else interesting, in general?
The problem being, besides the general extra complexity, that the
match statement's variable capture semantics are different to the
`as name` syntax already used by the except statement.
On 03/10/2021 16:47, Irit Katriel via Python-Dev wrote:
1. except *E as e: // except *(E1, E2) as e:
2. except* E as e: // except* (E1, E2) as e:
(that could be a useful feature actually (so maybe the * syntax should be reserved??), but that's another discussion)I vote #2, because `except *(e1, e2) as e:` could imply that this is splatting an arbitrary expression there - it looks like it will match any number of dynamically chosen exception types.
_______________________________________________
Python-Dev mailing list -- pytho...@python.org
To unsubscribe send an email to python-d...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Code of Conduct: http://python.org/psf/codeofconduct/
It seems like, for this to work, "group" would have to become a keyword. This would play havoc with a lot of existing code. I can't tell you how many times I've used the identifier "group" in my code, particularly when dealing with regular expressions.
Even making it a soft keyword, a la "await" in 3.5, would lead to
ambiguity:
group = KeyboardInterrupt
try:
while True:
print("thou can only defeat me with Ctrl-C")
except group as error:
print("lo, thou hast defeated me")
/arry
Message archived at https://mail.python.org/archives/list/pytho...@python.org/message/SZNDJPKT7WNWJHG4UDJ6D3BU6IN5ZXZO/
On 6 Oct 2021, at 12:06, Larry Hastings <la...@hastings.org> wrote:It seems like, for this to work, "group" would have to become a keyword.
This would play havoc with a lot of existing code.
Even making it a soft keyword, a la "await" in 3.5, would lead to ambiguity:
group = KeyboardInterrupt
try:
while True:
print("thou can only defeat me with Ctrl-C")
except group as error:
print("lo, thou hast defeated me")
Message archived at https://mail.python.org/archives/list/pytho...@python.org/message/SZNDJPKT7WNWJHG4UDJ6D3BU6IN5ZXZO/
Code of Conduct: http://python.org/psf/codeofconduct/
On 6 Oct 2021, at 12:06, Larry Hastings <la...@hastings.org> wrote:
It seems like, for this to work, "group" would have to become a keyword.
No, just like `match` and `case` didn't have to.
This would play havoc with a lot of existing code.
Extraordinary claims require extraordinary evidence, Larry. I maintain this will be entirely backwards compatible.
My claim is that making "group" a hard-coded keyword, visible at
all times, and thus no longer permitting use of "group" as an
identifier, would play havoc with a lot of existing code. I don't
think it's an extraordinary claim to say that "group" is a
reasonably popular identifier. For example, I offer the 1,117
uses of the word "group" in the Python 3.10.0 Lib/ directory
tree. (I admit I didn't review them all to see which ones were
actual identifiers, and which ones were in strings or
documentation.)
If the proposal is to add it as some "it's only a keyword in this
context" magic thing, a la how "async"/"await" were "soft
keywords" in 3.5, and if we otherwise would permit the word
"group" to be used as an identifier in perpetuity--okay, it won't
cause this problem.
We can even make its error message smarter than the default NameError, since -- as I claim -- it's terribly unlikely somebody would mean to name their dynamic exception collection "group".
I concede I don't completely understand PEP 654 yet, much less
the counter-proposals flying around right now. But it does seem
like "except group" has the potential to be ambiguous, given that
"group" is a reasonably popular identifier.
/arry
On 6 Oct 2021, at 18:05, Yury Selivanov <yseliv...@gmail.com> wrote:I don't like `except group` or any variant with soft keywords.
I'll list a few reasons here:1. `try: .. except group:` is a valid syntax today. And it will continue to be valid syntax. Having both `try: .. except group:` (catch exception `group`) and `try: .. except group E:` (catch exceptions of E into a group) in the same grammar worries me.1a. It can be especially confusing if someone has a local/global variable called `group`.
1b. Or, for example, if a user forgets to type `E` and leaves just `except group` it would fallback to the regular try..except behavior. And it would be a runtime error ("group" is undefined).
1c. This will be all even more complicated because syntax highlighters in IDEs and on sites like GitHub will likely just always highlight `except group` as a pair of keywords (even in `except group:` variant).
2. I'm not sure I like the "sound" of it. IMO it would make more sense to write `except all E`, but `all()` is a built-in and so this would be at odds with (1).
3. This is a niche feature. People who use async/await will get used to `except*` in no time. `except*` is also about unpacking in some metaphysical sense (looks similar enough to `*args` in function signatures to me) so I think it reads just fine.
So I'm -1 on `except group` or any variant that uses soft keywords. If the SC considers making `group` a proper keyword I can possibly change my mind on this.
Łukasz Langa wrote:
> Joking aside, since we allow any expression after 'except' 'group' then this is indeed ambiguous. In theory!
Another option (to remove the ambiguity) could be to move the “group” after the expression. Bonus points for reading more clearly:
except MemoryError group as e: …
except (KeyError, IndexError) group as e: …
except some + expression group as e: …
And edge-cases like this still work normally:
except some + group as e: …
_______________________________________________
Python-Dev mailing list -- pytho...@python.org
To unsubscribe send an email to python-d...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/pytho...@python.org/message/TW5I4Z3XKCSZC6IRXHNFVPZVLHEKI7O3/
Code of Conduct: http://python.org/psf/codeofconduct/
Another option (to remove the ambiguity) could be to move the “group” after the expression. Bonus points for reading more clearly:
except MemoryError group as e: …
except (KeyError, IndexError) group as e: …
except some + expression group as e: …
On 6 Oct 2021, at 18:48, Guido van Rossum <gu...@python.org> wrote:On Wed, Oct 6, 2021 at 9:01 AM Brandt Bucher <brandt...@gmail.com> wrote:Another option (to remove the ambiguity) could be to move the “group” after the expression. Bonus points for reading more clearly:
except MemoryError group as e: …
except (KeyError, IndexError) group as e: …
except some + expression group as e: …Argh. This would be very easy to overlook. As the senior author of PEP 654 I am going to go with "except*". Since it was shown that "except group" has ambiguous edge cases the proposals have gotten worse, which to me is a good sign that we need to stop.
_______________________________________________
Python-Dev mailing list -- pytho...@python.org
To unsubscribe send an email to python-d...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
On 6 Oct 2021, at 18:05, Yury Selivanov <yseliv...@gmail.com> wrote:
Now a moot point, but this could be a SyntaxWarning.