Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'exception': 0.03; 'exception.': 0.07; 'fixed,': 0.09; 'terminate.': 0.09; 'thrown': 0.09; 'bug': 0.10; 'client,': 0.16; 'distinct': 0.16; 'expression)': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'top-level': 0.16; 'wrote:': 0.17; 'fix': 0.17; 'instance,': 0.17; 'http': 0.22; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; "d'aprano": 0.29; 'steven': 0.29; 'code': 0.31; 'handle': 0.33; 'to:addr:python- list': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'minimum': 0.34; 'server': 0.35; 'generic': 0.35; 'doing': 0.35; 'received:209.85': 0.35; 'next': 0.35; 'but': 0.36; 'anything': 0.36; 'subject:with': 0.36; '(for': 0.37; 'systems,': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'your': 0.60; "you'll": 0.62; 'back': 0.62; 'between': 0.63; 'details': 0.63; '2013': 0.84; 'effectively,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=3Zd6ME+sqd58DTGL/bYFxrTVBm/gJ98z81u/vS2blQQ=; b=my/3qnNccFDscWG/DkcxsTOKN4+PSZOtwxEerskcXx4BsgVVNoYe28kC54zW1sDPh4 dN12WwctPYPIV7Bp6hPxIvQNj2W+fFwEYWXI2kh7LxievvXTjUEsWEf/nYfqFo9cORfs vMQQIo6dZR3aQJl0JFps2TzqC1xgdmsM9mdLeh5WfdTHUoaYB8qEN6+fH6ml2mYvcUTd qBm0m9esOBeJ0WBNZHwh+Vh9SZLXXDrM+bY0+MBTbtJnv78z69O2Taf2j9uL+gY9STbd cW3TH4SmhzEOFtViEf0IReC1se18a0Ot7lf/Ejf/apmrdp/3WBfIQnVKvZyM+YZuBl9h aXaQ== MIME-Version: 1.0 X-Received: by 10.220.218.195 with SMTP id hr3mr5792478vcb.70.1362272643097; Sat, 02 Mar 2013 17:04:03 -0800 (PST) In-Reply-To: <51329c25$0$30001$c3e8da3$5496439d@news.astraweb.com> References: <707df78f-9a67-4ce1-8dd3-095c75a7f7da@googlegroups.com> <51329c25$0$30001$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 3 Mar 2013 12:04:02 +1100 Subject: Re: Dealing with exceptions From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362272646 news.xs4all.nl 6962 [2001:888:2000:d::a6]:52543 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40379 On Sun, Mar 3, 2013 at 11:41 AM, Steven D'Aprano wrote: > But yes, in general, only catch the minimum you *know* you need to catch > and can deal with. Anything else is a bug in your code that needs to be > fixed, and you can't fix it if you never see the exception. With the exception (if you'll excuse the expression) of "framework" systems, where there's a distinct separation between "inside" and "outside". Often then, the "outside" will catch any exception thrown by the "inside" and deal with it in some generic way (for instance, a web server might log the details and return HTTP 500 to the client, then go back and handle the next request). Effectively, this is doing the job of the top-level exception handler: log the exception (to the console) and terminate. ChrisA