James Mills wrote:
On Tue, May 10, 2011 at 10:40 AM, Kyle T. Jones
<onexpadrem...@evomeryahoodotyouknow.com> wrote:
It has been hard for me to determine what would constitute overuse.

A rule of thumb I always follow and practice is:

"Let the error lie where it occurred."

or

"Don't hide errors.".

It's good practice to follow IHMO as it makes it easier to find
the source of defects in your function(s). If you constantly
do things like try/except/log then it makes finding the source
harder and may make it harder to identify what caused it.
You can reraise the exception without loosing the stack trace.

try:
...
except SomeException, exc:
log(exc)
print 'Hello world'
raise # "raise exc" would loose the original stack trace

JM

PS : "code that crashes could use improvement, but incorrect code that doesn’t crash is a horrible nightmare." (I don't know the author)

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to