<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 18, 2014 at 11:06 PM, Chris Angelico <span dir="ltr"><<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":2wz" style="overflow:hidden">However, I'm removing two parts of the proposal: ... chaining of</div></blockquote>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":2wz" style="overflow:hidden">
excepts (use parens, "(expr except Exception1: default1) except<br>
Exception2: default2").<br></div></blockquote></div><br>There are two problems with trying to leave this out.</div><div class="gmail_extra"><br></div><div class="gmail_extra">First, you say "use parens" but no use of parenthesis can have the same effect. The alternative you give:</div>
<div class="gmail_extra"><font face="courier new, monospace"> (expr except E1: default1) except E2: default2</font> </div><div class="gmail_extra">is not the same as the chained form. This catches E2 in both the evaluation of E1 <b><u>and</u></b> the evaluation of default1 while the chained form catches both exceptions only in the evaluation of E1. And putting parens anywhere else doesn't do it either.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Second, isn't an except expression like any other expression which can be used anywhere an expression can be? So that means that writing something that looks like a chained expression without parenthesis <u><b>will</b></u> be a valid expression and will have to have some interpretation (depending on whether except is left associative or right associative.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Given that, I think it is better to define it as chained now rather than leaving people to think it's chained and never being able to add it in the future (since that will change the semantics of existing code). This is analogous to handling a < b < c: it's a bug magnet in C for inexperienced programmers but can't be changed without breaking code. Starting from scratch in Python, it could be chained.</div>
<div class="gmail_extra"><br clear="all"><div><div dir="ltr"><font face="arial, helvetica, sans-serif">--- Bruce<br></font><div><div><font face="arial, helvetica, sans-serif">Learn how hackers think: <a href="http://j.mp/gruyere-security" target="_blank">http://j.mp/gruyere-security</a></font></div>
</div></div></div>
</div></div>