<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 29 April 2018 at 21:24, 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"><span class="">On Sun, Apr 29, 2018 at 6:03 PM, Nick Coghlan <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br>
> The challenge with doing this implicitly is that there's no indication<br>
> whatsoever that the two "e"'s are different, especially given the<br>
> longstanding precedent that the try/except level one will overwrite any<br>
> existing reference in the local namespace.<br>
<br>
</span>My intention is that the "except" statement IS the indication that<br>
they're different. Now that the name gets unbound at the exit of the<br>
clause, the only indication that it overwrites is that, after "except<br>
Exception as e:", any previous e has been disposed of. I'd hardly call<br>
that a feature. Can you show me code that actually DEPENDS on this<br>
behaviour?<br></blockquote><div><br clear="all"></div></div>That's not the bar the proposal needs to meet, though: it needs to meet the bar of being *better* than the status quo of injecting an implicit "del e" at the end of the suite.<br><br>While the status quo isn't always convenient, it has two main virtues:<br><br></div><div class="gmail_extra">1. It's easily explained in terms of the equivalent "del" statement<br></div><div class="gmail_extra">2. Given that equivalence, it's straightforward to avoid the unwanted side effects by either adjusting your exact choices of names (if you want to avoid overwriting an existing name), or else by rebinding the caught exception to a different name (if you want to avoid the exception reference getting dropped).<br><br></div><div class="gmail_extra">I do agree that *if* sublocal scopes existed, *then* they would offer a reasonable implementation mechanism for block-scoped name binding in exception handlers. However, exception handlers don't offer a good motivation for *adding* sublocal scopes, simply because the simpler "implicitly unbind the name at the end of the block" approach works well enough in practice.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Cheers,<br></div><div class="gmail_extra">Nick.<br></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>   |   Brisbane, Australia</div>
</div></div>