<div class="gmail_quote">On Mon, Jan 19, 2009 at 9:10 AM, Gerald Britton <span dir="ltr">&lt;<a href="mailto:gerald.britton@gmail.com">gerald.britton@gmail.com</a>&gt;</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;">
&nbsp; &nbsp;&nbsp; g = (n for n in range(100) if n*n &lt; 50)<br>
<br>
 &nbsp;would yield 0, 1, 2, 3, 4, 5, 6 and 7, but would also consider<br>
 &nbsp;the numbers from 8 to 99 and reject them all since n*n &gt;= 50 for<br>
 &nbsp;numbers in that range. &nbsp;Allowing for a &quot;while&quot; clause would allow<br>
 &nbsp;the redundant tests to be short-circuited:<br>
</blockquote></div><br>Instead of using a &quot;while&quot; clause, the above example could simply be rewritten:<br><br>&nbsp;&nbsp;&nbsp; g = (n for n in range(8))<br><br>I appreciate that this is a toy example to illustrate the syntax.&nbsp; Do you have some slightly more complex examples, that could not be rewritten by altering the &quot;in&quot; clause?<br>
<blockquote style="margin: 1.5em 0pt;">--<br>
Daniel Stutzbach, Ph.D.<br>
President, <a href="http://stutzbachenterprises.com">Stutzbach Enterprises, LLC</a>
</blockquote>