Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!matrix.darkstorm.co.uk!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!news2.arglkargh.de!news.wiretrip.org!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'handled': 0.03; 'python': 0.07; 'caller': 0.09; 'jones': 0.09; 'to:name:python list': 0.09; 'am,': 0.14; 'wrote:': 0.14; '"don\'t': 0.16; 'defects': 0.16; 'language)': 0.16; 'tue,': 0.20; 'programming': 0.20; 'header:In- Reply-To:1': 0.22; 'driven': 0.23; 'message-id:@mail.gmail.com': 0.28; 'received:209.85.161': 0.29; 'error': 0.29; 'subject:?': 0.29; '(as': 0.29; 'points': 0.31; 'solved': 0.31; 'it.': 0.31; 'determine': 0.31; 'to:addr:python-list': 0.32; 'source': 0.32; 'things': 0.33; 'test': 0.33; 'caught': 0.35; 'rule': 0.35; 'finding': 0.35; 'lie': 0.35; 'subject:/': 0.36; 'should': 0.37; 'received:209.85': 0.37; 'received:google.com': 0.38; 'but': 0.38; 'errors': 0.39; 'to:addr:python.org': 0.39; 'where': 0.39; 'received:209': 0.39; 'would': 0.40; "it's": 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'favor': 0.64; 'harder': 0.65; 'contracts': 0.68; 'constitute': 0.91 MIME-Version: 1.0 In-Reply-To: References: From: James Mills Date: Tue, 10 May 2011 11:09:01 +1000 Subject: Re: Overuse of try/except/else? To: python list Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1304989764 news.xs4all.nl 41103 [::ffff:82.94.164.166]:37533 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5045 On Tue, May 10, 2011 at 10:40 AM, Kyle T. Jones 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"