If you&#39;re not allowed to raise the exception, why not just return it?<div><br></div><div>I can imagine a pattern where every function was a tuple return value (as stated previously) where the first item is the real return value, and the 2nd item is either None or an instance of an Exception. </div>
<div><br></div><div>Then, you could wrap every function in your entire system with a decorator that looked at these return values, and if the Exception part was non-None, then it would return back out to the caller, possibly calling some cleanup function that would be specified as an argument to the decorator.  I can code up some kind of rudimentary example if you&#39;d like. </div>
<div><br></div><div>Of course, this path gets dangerously close to &quot;let&#39;s do exactly the same thing as exceptions but not use the built in language features ourselves and rewrite the whole thing from scratch so we have a maintenance nightmare&quot;.  </div>
<div><br></div><div>Is it too late to quit and go work somewhere else?</div><div><br></div><div>Steve<br><br><div class="gmail_quote">On Tue, Oct 5, 2010 at 9:20 PM, Tung Wai Yip <span dir="ltr">&lt;<a href="mailto:tungwaiyip@yahoo.com">tungwaiyip@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">The recipe only collect information from the stack. It won&#39;t resume execution after an exception is throw.<br>
<br>
It maybe easier to use a wrapper for all function call.<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

def call(func, *args, **kwargs):<br>
</blockquote></blockquote></blockquote>
...   try:<br>
...     return func(*args,**kwargs)<br>
...   except:<br>
...     # auto ignore exception!<br>
...     return<br>
...<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

res = call(open,&#39;dummy file&#39;,&#39;rb&#39;)<br>
# look mom, no exception!<br>
</blockquote></blockquote></blockquote>
<br>
Wai Yip<div><div></div><div class="h5"><br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tue, Oct 5, 2010 at 7:15 PM, Nick S Kanakakorn &lt;<a href="mailto:bbdada@gmail.com" target="_blank">bbdada@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
My work place has imposed a rules for no use of exception (catching is<br>
allowed).  If I have code like this<br>
</blockquote>
<br>
I&#39;ve seen this anti-pattern up close. There is no Pythonic answer -<br>
exceptions are the answer. I&#39;ve adapted this recipe[0] to get all<br>
kinds of information from the call stack when something fails,<br>
although it depends on the failing function to call it... Definitely a<br>
pain. I feel for you. Hopefully the code is solid enough not to need<br>
too much debugging.<br>
<br>
For the curious, the rationale I heard is that failure isn&#39;t important<br>
enough to stop the execution or the minor variant, failures are<br>
irrelevant to the execution.<br>
<br>
[0] <a href="http://code.activestate.com/recipes/52215/" target="_blank">http://code.activestate.com/recipes/52215/</a><br>
_______________________________________________<br>
Baypiggies mailing list<br>
<a href="mailto:Baypiggies@python.org" target="_blank">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>
<br>
<br></div></div><div class="im">
-- <br>
Using Opera&#39;s revolutionary e-mail client: <a href="http://www.opera.com/mail/" target="_blank">http://www.opera.com/mail/</a><br>
_______________________________________________<br></div><div><div></div><div class="h5">
Baypiggies mailing list<br>
<a href="mailto:Baypiggies@python.org" target="_blank">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>
</div></div></blockquote></div><br></div>