Brett,
This is a side question about how tuples are handled in python, perhaps in general.
My previous understanding is that what makes a tuple is the comma, not the parentheses.
So, unless the handling of tuples in the except case is different, is there a difference between evaluating cases like these:
a, _, c = 1, 2, 3
(a, _, c) = (1, 2, 3)
There can be other variations but the question I have is whether you can say one of many similar methods will create a (temporary) tuple while others don’t?
The case you are discussing can perhaps be easy to investigate by looking at the byte code produced in these two variant of
... except alpha, beta ...
where the ...
just means there will be more code on lines above and below, versus:
... except (alpha, beta) ...
Python does overload usage of parentheses in various ways but in many contexts, such as using parentheses for grouping, the code produced if you are not changing precedence rules would probably be the same but the parentheses used would make it easier for human readers of the code to be clear on what it will do.
I am not expressing an opinion here on whether the parentheses here should be optional, but just asking if this observation is correct, or if a tuple is automatically created just because of the comma.
Avi