<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#330033">
<div class="moz-cite-prefix">On 2/27/2014 7:46 PM, Chris Angelico
wrote:<br>
</div>
<blockquote
cite="mid:CAPTjJmrYMyQsPspsuDR=7q6zpivTabTO7ZV6UhZLyvSO5FEMEg@mail.gmail.com"
type="cite">
<pre wrap="">On Fri, Feb 28, 2014 at 1:12 PM, Glenn Linderman <a class="moz-txt-link-rfc2396E" href="mailto:v+python@g.nevcal.com"><v+python@g.nevcal.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Yes. But the point is really the location of the (), sorry if my "nice
extension" comment is throwing you off that track.
</pre>
</blockquote>
<pre wrap="">
Ah! I see.
We touched on this syntax on -ideas, but at the time, the proposed
syntax didn't have parens around the outside. Either location will
solve most of the same problems (like precedence/associativity versus
multiple except clauses), but shrinking down to just the exception
list and default value makes it look very different. It looks like
what's inside should be an expression, which it isn't. What's the
advantage of this form? What's its key advantage over the
parens-around-the-whole-thing form?
</pre>
</blockquote>
<br>
Key advantage to me is that if a function call or other expression
may produce multiple exceptions, the syntax doesn't require
repeating the "except" over and over. By not repeating the except
over and over, there is less ambiguity about what expression the
Exception-lists apply to, when there is more than one Exception list
in the expression. Whereas the current PEP syntax has ambiguity
regarding how to interpret a-expr except except-list-b: b-expr
except except-list-c: c-expr (does the 2nd except apply to a-expr or
b-expr?), without parentheses, and, as far as I am concerned, even
with the parentheses, this syntax makes it very clear that each of
the Exception-lists apply to a-expr.<br>
<br>
Key advantage to others may be that because the : is within the ()
[and the leading ( is quite nearby, making it obvious], it is less
likely to be considered a statement boundary, and more easily
explained as a special type of list syntax... not _really_ a list,
because it is really code to be executed somewhat sequentially
rather than data, and lists don't have : ... and not _really_ a dict
constant, which does have :, because the Exception is not _really_ a
key, but the syntax can draw on analogies with the dict constant
syntax which will help people remember it, and even sort of
understand that there is a pair-wise relationship between the
Exception-list and the expression after the :, without repeating the
except over and over.<br>
</body>
</html>