<font color='black' size='2' face='arial'>That's a break....<br>
<br>
<br>
<div style="font-family:arial,helvetica;font-size:10pt;color:black">-----Original Message-----<br>
From: Shane Green <shane@umbrellacode.com><br>
To: Ned Batchelder <ned@nedbatchelder.com><br>
Cc: python-ideas <python-ideas@python.org><br>
Sent: Tue, Jun 25, 2013 1:13 pm<br>
Subject: Re: [Python-ideas] Is this PEP-able? for X in ListY while conditionZ:<br>
<br>
<div id="AOLMsgPart_2_905d5914-b07e-4c55-8d85-4d0c6d762cd6">
<div class="aolReplacedBody" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">[x for x in l if x < 10 else break]?
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<div>
<div>On Jun 25, 2013, at 10:08 AM, Ned Batchelder <<a removedlink__1132442614__href="mailto:ned@nedbatchelder.com">ned@nedbatchelder.com</a>> wrote:</div>
<br class="Apple-interchange-newline"><blockquote type="cite">
<div text="#000000" bgcolor="#FFFFFF" 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;">You don't have to: use the break statement, that's what it's for. About people teaching students not to use it: the existence of bad teachers teaching silly ideas is not a reason to add syntax to Python.<br>
<br>
--Ned.<br>
<br>
<div class="moz-cite-prefix">On 6/25/2013 10:46 AM,<span class="Apple-converted-space"> </span><a class="moz-txt-link-abbreviated" removedlink__1132442614__href="mailto:jimjhb@aol.com">jimjhb@aol.com</a><span class="Apple-converted-space"> </span>wrote:<br>
</div>
<blockquote type="cite"><font size="2" face="arial"><br>
<div style="font-family: arial, helvetica; font-size: 10pt;">
<div id="AOLMsgPart_1_6fefd5c5-1a1a-4de7-83d4-1d0967ebd3b6"><font size="2" face="arial">You shouldn't have to invoke takewhile and a lambda just to break out of for loop.<br>
<div style="font-size: 10pt;">
<div id="AOLMsgPart_0_bb27e8f8-4c9b-49b6-b5a4-d92139d83998" style="margin: 0px; font-size: 12px; background-color: rgb(255, 255, 255);"><pre style="font-size: 9pt;"><tt><a style="font-family: Tahoma, Verdana, Arial, sans-serif;">>http://docs.python.org/2/library/itertools.html#itertools.takewhile</a><font face="Tahoma, Verdana, Arial, sans-serif">
>
>for item in takewhile(lambda x: x < 5, range(10)):
> pass
</font><font face="Arial, Helvetica, sans-serif">></font><font face="Tahoma, Verdana, Arial, sans-serif">>
>> [People who avoid the 'break' by functionalizing an inner portion of the
>> loop are just kidding themselves and making their own code worse, IMO.
>> Takewhile from itertools also works, but that's clumsy and wordy as well.]
>>
</font></tt></pre></div>
</div>
</font></div>
</div>
</font><br>
<fieldset class="mimeAttachmentHeader"></fieldset><br>
<pre>_______________________________________________
Python-ideas mailing list
<a class="moz-txt-link-abbreviated" removedlink__1132442614__href="mailto:Python-ideas@python.org">Python-ideas@python.org</a>
<a class="moz-txt-link-freetext" target="_blank" removedlink__1132442614__href="http://mail.python.org/mailman/listinfo/python-ideas">http://mail.python.org/mailman/listinfo/python-ideas</a>
</pre></blockquote><br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a removedlink__1132442614__href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a target="_blank" removedlink__1132442614__href="http://mail.python.org/mailman/listinfo/python-ideas">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</div>
</blockquote></div>
<br>
</div>
</div>
</div>
<div id="AOLMsgPart_3_905d5914-b07e-4c55-8d85-4d0c6d762cd6" style="margin: 0px;font-family: Tahoma, Verdana, Arial, Sans-Serif;font-size: 12px;color: #000;background-color: #fff;">
<pre style="font-size: 9pt;"><tt>_______________________________________________
Python-ideas mailing list
<a removedlink__1132442614__href="mailto:Python-ideas@python.org">Python-ideas@python.org</a>
<a removedlink__1132442614__href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a>
</tt></pre>
</div>
<!-- end of AOLMsgPart_3_905d5914-b07e-4c55-8d85-4d0c6d762cd6 -->
</div>
</font>