[Baypiggies] Python way to avoid usage of raise

Tung Wai Yip tungwaiyip at yahoo.com
Wed Oct 6 06:20:35 CEST 2010

The recipe only collect information from the stack. It won't resume  
execution after an exception is throw.

It maybe easier to use a wrapper for all function call.

>>> def call(func, *args, **kwargs):
...   try:
...     return func(*args,**kwargs)
...   except:
...     # auto ignore exception!
...     return
>>> res = call(open,'dummy file','rb')
>>> # look mom, no exception!

Wai Yip

> On Tue, Oct 5, 2010 at 7:15 PM, Nick S Kanakakorn <bbdada at gmail.com>  
> wrote:
>> Hi,
>> My work place has imposed a rules for no use of exception (catching is
>> allowed).  If I have code like this
> I've seen this anti-pattern up close. There is no Pythonic answer -
> exceptions are the answer. I've adapted this recipe[0] to get all
> kinds of information from the call stack when something fails,
> although it depends on the failing function to call it... Definitely a
> pain. I feel for you. Hopefully the code is solid enough not to need
> too much debugging.
> For the curious, the rationale I heard is that failure isn't important
> enough to stop the execution or the minor variant, failures are
> irrelevant to the execution.
> [0] http://code.activestate.com/recipes/52215/
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

More information about the Baypiggies mailing list