EXCELLENT NEWS, Nick!!!<div><br></div><div>Raising is in PEP-8 (<a href="http://www.python.org/dev/peps/pep-0008/">http://www.python.org/dev/peps/pep-0008/</a>) and I personally couldn&#39;t find a pythonic way to do this otherwise...</div>
<div><br></div><div>Glen<br><br><div class="gmail_quote">On Wed, Oct 6, 2010 at 2:50 PM, Nick S Kanakakorn <span dir="ltr">&lt;<a href="mailto:bbdada@gmail.com">bbdada@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;">
There is a happy news here today.  The use of raise exception is allowed again after I put some coding in using this convention:<div><br></div><div>exitcode, actual_result = f1()</div><div>if exitcode &lt; 0: return exitcode</div>

<div>.... continue something useful with actual_result</div><div><div>exitcode, actual_result = f1()</div><div><div></div><div class="h5"><div><br></div><div><br></div><br><div class="gmail_quote">On Tue, Oct 5, 2010 at 7:15 PM, Nick S Kanakakorn <span dir="ltr">&lt;<a href="mailto:bbdada@gmail.com" target="_blank">bbdada@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="gmail_quote"><div>Hi,</div><div><br></div><div>My work place has imposed a rules for no use of exception (catching is allowed).  If I have code like this</div>

<div><br></div><div>def f1()</div><div>  if bad_thing_happen():</div>
<div>     raise Exception(&#39;bad stuff&#39;)</div>
<div>  ...</div><div>  return something</div><div><br></div><div>I could change it to</div><div><br></div><div>def f1()</div><div>  if bad_thing_happen():</div><div>    return [-1, None]</div><div>  ...</div><div>  return [0, something]</div>



<div><br></div><div>f1 caller would be like this</div><div><br></div><div>def f1_caller():</div><div>  code, result = f1(param1)</div><div>  if code &lt; 0:</div><div>    return code</div><div>  actual_work1()</div><div>


  # call f1 again</div>
<div>  code, result = f1(param2)</div><div>  if code &lt; 0:</div><div>    return code</div><div>  actual_work2()</div><div>  ...</div><div><br></div><div>Are there more elegant ways than this in Python ?</div><div><br></div>


<div>Thanks,</div>
<div>Nick K</div>
</div><br>
</blockquote></div><br><br clear="all"><br></div></div>-- <br>-Nick Kanakakorn<br>
</div>
<br>_______________________________________________<br>
Baypiggies mailing list<br>
<a href="mailto:Baypiggies@python.org">Baypiggies@python.org</a><br>
To change your subscription options or unsubscribe:<br>
<a href="http://mail.python.org/mailman/listinfo/baypiggies" target="_blank">http://mail.python.org/mailman/listinfo/baypiggies</a><br></blockquote></div><br><br clear="all"><br>-- <br>Whatever you can do or imagine, begin it;<br>
boldness has beauty, magic, and power in it.<br><br>-- Goethe <br>
</div>