[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):
... return func(*args,**kwargs)
... # auto ignore exception!
>>> res = call(open,'dummy file','rb')
>>> # look mom, no exception!
> On Tue, Oct 5, 2010 at 7:15 PM, Nick S Kanakakorn <bbdada at gmail.com>
>> 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 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.
>  http://code.activestate.com/recipes/52215/
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the Baypiggies