The problem with this while loop is if your random value doesn&#39;t lie between the mentioned range then ur 100% cpu would be utilized. The one thing u can do is to sleep for some time lets say 0.5 sec after every while loop iteration , in this case ur cpu utilization will go down.<div>
<br></div><div>--nitin <br><br><div class="gmail_quote">On Mon, Aug 23, 2010 at 8:21 PM, bob gailer <span dir="ltr">&lt;<a href="mailto:bgailer@gmail.com">bgailer@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"> On 8/23/2010 1:00 AM, Greg Bair wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have a method (I&#39;ll call it foo) that will either return None or an object depending on a random value generated.  What I want to happen is that if I call foo(), i.e, f = foo() and it returns None, to re-call it until it returns something else.  I would think this would be done with a while loop, but can&#39;t seem to get the details right.<br>

</blockquote>
<br></div>
Even though a while will work, you will have tied up the CPU until the loop terminates. This is never a good idea.<br>
<br>
What is your higher level goal?<div class="im"><br>
<br>
-- <br>
Bob Gailer<br>
919-636-4239<br>
Chapel Hill NC<br>
<br>
_______________________________________________<br></div><div><div></div><div class="h5">
Tutor maillist  -  <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</div></div></blockquote></div><br></div>