<br><br><div class="gmail_quote">On Wed, Oct 7, 2009 at 10:27 AM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com">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 class="im">Yuvgoog Greenle wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I don't like your "except" and "else" only because it's not obvious<br>
when they execute.<br>
<br>
btw your example breaks the current "for..else" search idiom. C,<br>
suite_if_loop_is_not_broken, should be labelled<br>
suite_if_loop_is_not_broken_and_not_empty in your example code.<br></blockquote></div></blockquote><div><br></div><div>Some of the discussion makes it clear that it wasn't clear that my translation was for the for/except/else case and would not change the for/else case we have today. Here's a translation that covers both cases:</div>

<div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><div>do_except = True</div><div>do_else = False</div><div>for i in SEQ:</div><div>  do_except = False</div>

<div>  A</div><div>else:</div><div>  do_else = True</div><div>if do_except:</div><div>  B  # suite_if_loop_body_is_not_executed</div><div>elif do_else:</div><div>  C</div><div><br></div><div>Regarding Guido's comment about the use of 'except' here being it makes people think of exceptions, I think it makes people think of exceptional cases too. If I could commandeer the Python time machine and rollback for/else, what I'd do is:</div>

<div><br></div><div>for i in SEQ:</div><div>  suite</div><div>except None:</div><div>  suite  # executed if SEQ is empty</div><div>except NoBreak:</div><div>  suite  # executed if loop did not break excluding except None if present</div>

<div><br></div><div>NoBreak is not a keyword; it's a special value.</div></span></div></div>