<br><br><div class="gmail_quote">On Wed, Jun 6, 2012 at 10:59 PM, Don Spaulding <span dir="ltr"><<a href="mailto:donspauldingii@gmail.com" target="_blank">donspauldingii@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><br><div class="gmail_quote">On Wed, Jun 6, 2012 at 7:15 PM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>On 07/06/2012 00:20, Alice Bevan–McGregor wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Howdy!<br>
<br>
Was teaching a new user to Python the ropes a short while ago and ran<br>
into an interesting headspace problem: the for/else syntax fails the<br>
obviousness and consistency tests.  When used in an if/else block the<br>
conditional code is executed if the conditional passes, and the else<br>
block is executed if the conditional fails.  Compared to for loops<br>
where the for code is repeated and the else code executed if we<br>
"naturally fall off the loop".  (The new user's reaction was "why the<br>
hoek would I ever use for/else?")<br>
<br>
</blockquote></div>
I find the easiest way to think of it is imagine you're searching a<br>
list. If you find what you're looking for you break, else you do<br>
something else.</blockquote><div><br></div><div>I think the problem is that "break" doesn't sound like a positive, it sounds like a negative, and indeed it means we effectively *ignore* the rest of the list.  So when you get to the "else" it's like an English double-negative, awkward to understand.  Perhaps even more because you're effectively else-ing the break, not the for, so the indentation level even seems off.</div>

<div><br></div><div>Backwards-compatibility issues aside, renaming "else" to "finally" sounds like a really great idea.</div></div></blockquote><div><br></div><div>No: "finally" implies that it is going to be done at the end of the block; the "else" clause is *not* executed if a break occurs - hence it has a different semantics.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div><br></div></div>
<br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
<br></blockquote></div><br>