<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Create “stop” which is basically an alias for “break” but always used in the way that’s not considered bad practice.<div><br></div><div><br></div><div>[x for x in l if x < 100 else stop]</div><div><br></div><div><br></div><div><br><div><div>On Jun 25, 2013, at 12:22 PM, <a href="mailto:jimjhb@aol.com">jimjhb@aol.com</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font size="2" face="arial"><font face="Arial, Helvetica, sans-serif"><br><br><br></font><div style="font-size: 10pt;"><font face="Arial, Helvetica, sans-serif">>-----Original Message-----<br>>From: Stephen J. Turnbull <<a href="mailto:stephen@xemacs.org">stephen@xemacs.org</a>><br>>To: jimjhb <<a href="mailto:jimjhb@aol.com">jimjhb@aol.com</a>><br>>Cc: mertz <<a href="mailto:mertz@gnosis.cx">mertz@gnosis.cx</a>>; python-ideas <<a href="mailto:python-ideas@python.org">python-ideas@python.org</a>><br>>Sent: Tue, Jun 25, 2013 3:07 pm<br>>Subject: Re: [Python-ideas] Is this PEP-able? for X in ListY while conditionZ:<br><br></font><div id="AOLMsgPart_0_f67f675c-67f3-4a69-aa77-aff9edefd1f2" style="margin: 0px; font-size: 12px; background-color: rgb(255, 255, 255);"><pre style="font-size: 9pt;"><tt><font face="Arial, Helvetica, sans-serif"><a removedlink__222575731__href="mailto:jimjhb@aol.com">></a><a href="mailto:jimjhb@aol.com">jimjhb@aol.com</a> writes:

 >> Main issue seems to be that programmers "shouldn't" shy away from
 >> 'break' (I can kind of see the argument both ways) but they do.

>I guess I just hang around in the wrong company, because I don't see
>it.  Where can I find these programmers who shy away from these
>constructs?</font></tt></pre><pre style="font-size: 9pt;"><tt><font face="Arial, Helvetica, sans-serif">Here:</font></tt></pre><pre style="font-size: 9pt;"><tt><font face="Arial, Helvetica, sans-serif"><a target="_blank" href="http://www.csee.umbc.edu/courses/201/spring13/standards.shtml" style="color: blue; cursor: pointer; font-size: small; white-space: normal;">http://www.csee.umbc.edu/courses/201/spring13/standards.shtml</a>

 >> I think for deserves a 'while' because it is really sparing in its
 >> implementation (no index, no explicit bounds check) and so deserves
 >> a clean way to prematurely terminate the loop if needed.

>But this idea lacks coherence, in that 'break' statement syntax is far
>more expressive than a 'while' clause in the 'for' statement can be.
>The 'while' condition needs to satisfy expression syntax and be a
>function of the loop variable.</font></tt></pre><pre style="font-size: 9pt;"><tt><font face="Arial, Helvetica, sans-serif">I didn't think the while had to be a function of the loop variable.</font></tt></pre><pre style="font-size: 9pt;"><tt><font face="Arial, Helvetica, sans-serif">end_condition = False</font></tt></pre><pre style="font-size: 9pt;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 9pt;">for X in ListY while end_condition is False:</span></pre><pre style="font-size: 9pt;"><tt><font face="Arial, Helvetica, sans-serif">>But 'break' can be used at the top of
>the loop, bottom, or elsewhere while the new syntax can only implement
>one of those.  And the 'break' condition need not be a function of the
>loop variable.

>On the other hand, in list comprehensions and generator expressions,
>the syntactic and functional restrictions on the condition need to be
>satisfied anyway.
</font>
By the way:

 > David Mertz writes:

 >> attendees = {guest:guest.plus_N for guest in waiting_list while
 >> not room_full()}
 >>
 >> This would actually produce the same result as:
 >>
 >> attendees = {guest:guest.plus_N for guest in waiting_list if not
 >> room_full()}

Not necessarily.  waiting_list might be an infinite iterator.

Steve
</tt></pre></div></div></font>_______________________________________________<br>Python-ideas mailing list<br><a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>http://mail.python.org/mailman/listinfo/python-ideas</div></blockquote></div><br></div></body></html>