Overuse of try/except/else?

James Mills prologic at shortcircuit.net.au
Mon May 9 21:09:01 EDT 2011


On Tue, May 10, 2011 at 10:40 AM, Kyle T. Jones
<onexpadREMOVE at 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.

I favor Test Driven Development (TDD) over Contracts in Python
(as Python is a dynamic programming language) but errors should
be handled and caught by the caller - not the callee.

My 2c, others may have other points of view...

cheers
James

-- 
-- James Mills
--
-- "Problems are solved by method"



More information about the Python-list mailing list