<br><br><div class="gmail_quote">On Thu, Oct 8, 2009 at 10:53 PM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Fri, 9 Oct 2009 03:19:35 am Stephen J. Turnbull wrote:<br>
> Masklinn writes:<br>
>  > Both would, because in both cases the `else:` clause serves no<br>
>  > purpose whatsoever. It's noise.<br>
><br>
> Tut, tut.  In Nick's proposal, both would raise because there is an<br>
> "else:" but there is no break.  I doubt the Python compiler would add<br>
> the editorial comment about "noise," though.<wink><br>
<br>
</div>But that's exactly what it is doing, even if it doesn't use the<br>
word "noise". It's making an editorial judgement that perfectly legal<br>
code that does exactly what it is meant to do is somehow "bad" and<br>
requires a warning.<br></blockquote><div><br>The fact that code is currently legal (or illegal) does not stop us<br>from making judgments about whether it should or should not be <br>legal- see the current discussion about relaxing the restriction <br>
on decorators if you want an example. The only difference here<br>is that instead of attempting to outright forbid that behavior, the<br>proposal is to issue a warning notifying the programmer that<br>they have probably screwed up, like pretty much everybody<br>
providing code examples in the course of this discussion.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
If I see a message SyntaxWarning('for...else with no break'), my<br>
immediate response is "Yes, so what?". The code runs, it runs<br>
correctly.<br></blockquote><div><br>You're switching definitions of "what it is meant to do" from<br>one based on the idea that the compiler is always right to<br>one based on the idea that there's some higher definition of<br>
correctness.<br> <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
People write code incrementally. A for...else block that ends up<br>
including a break may go through many edit-compile-run cycles before<br>
the break actually gets inserted. I shouldn't have to add a<br>
spurious "if False: break" to shut the compiler up during those<br>
incremental edits.<br></blockquote><div><br>So what? Suppress the warning if you want, otherwise, listen<br>to it, it's telling you that your code probably isn't doing what<br>you intended it to do. That's the sort of thing I'd generally<br>
like to know while in the middle of the dev cycle.<br> <br><br>Geremy Condra<br></div></div><br>