On Sat, Jul 18, 2009 at 5:58 AM, Lie Ryan <span dir="ltr"><<a href="mailto:lie.1296@gmail.com">lie.1296@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
<br>
</div>If you're looking for speed, you should be aware that a failed<br>
try-clause is quite expensive in python and often (as in this case)<br>
codes using exception can be less readable than the one without since a<br>
program's flow in the case of exception is not linear (the non-linear<br>
execution is useful for quickly breaking out from nests of clauses, but<br>
not necessary in this case).</blockquote><div><br>Was not aware that myself. Noted.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
Semantically, it is also wrong. Not finding the n'th prime in the cache<br>
is not really an exceptional case.<br>
<br>
If you insists on using a try-except clause, use it this way:<br>
<br>
</blockquote><div>Well, I don't have to use try-except. I think I got another idea though. I could use an internal counter to keep track of how many prime numbers have generated, and if not enough, generate more.<br>
<br>Thanks.<br><br clear="all">Ching-Yun "Xavier" Ho, Technical Artist<br><br>Contact Information<br>Mobile: (+61) 04 3335 4748<br>Skype ID: SpaXe85<br>Email: <a href="mailto:contact@xavierho.com">contact@xavierho.com</a><br>
Website: <a href="http://xavierho.com/">http://xavierho.com/</a><br></div></div><br>