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