Abuse of the object-nature of functions?
Carl J. Van Arsdall
cvanarsdall at mvista.com
Tue Jul 11 13:17:07 EDT 2006
Sybren Stuvel wrote:
> Ant enlightened us with:
>
>> try:
>> assertion = callable.is_assertion
>> except:
>> pass
>>
>
> Try to make a habit out of catching only the exceptions you know will
> be thrown. Catching everything generally is a bad idea. In this case,
> my bet is that catching AttributeError is enough.
>
>
What about doing exception kind of like a C switch statement with a
default case:
try:
do_something()
except TypeError:
fix_something()
except:
print "Unknown error, you are doomed"
traceback.print_exc() #something to print the traceback
exit_gracefully()
Is this frowned upon? You still handle the error and you know where it
happened and what happened. Anything wrong with this? I don't like the
idea of my system crashing for any reason.
-carl
--
Carl J. Van Arsdall
cvanarsdall at mvista.com
Build and Release
MontaVista Software
More information about the Python-list
mailing list