Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!feeder.news-service.com!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'received:209.85.213.46': 0.07; 'received:mail-yw0-f46.google.com': 0.07; 'to:name:python list': 0.09; 'pm,': 0.11; 'exception': 0.12; 'wrote:': 0.14; "'hello": 0.16; 'reraise': 0.16; 'trace.': 0.16; 'stack': 0.16; 'trace': 0.19; 'tue,': 0.20; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'received:209.85.213': 0.23; 'referring': 0.23; 'message- id:@mail.gmail.com': 0.28; 'raise': 0.29; 'subject:?': 0.29; 'solved': 0.31; 'it.': 0.31; 'to:addr:python-list': 0.32; '...': 0.32; "i've": 0.33; 'print': 0.35; 'point': 0.35; 'try:': 0.35; 'subject:/': 0.36; 'however': 0.37; 'received:209.85': 0.37; 'received:google.com': 0.38; 'to:addr:python.org': 0.39; 'where': 0.39; 'received:209': 0.39; 'except': 0.39; 'logs': 0.40; 'would': 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'loose': 0.68; 'exc:': 0.84 MIME-Version: 1.0 In-Reply-To: <4DC90692.50903@sequans.com> References: <4DC90692.50903@sequans.com> From: James Mills Date: Wed, 11 May 2011 13:37:57 +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: 22 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305085100 news.xs4all.nl 81483 [::ffff:82.94.164.166]:33580 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5091 On Tue, May 10, 2011 at 7:34 PM, Jean-Michel Pichavant wrote: > 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 Valid point :) However I was referring to real experience where I've seen code that "catches all any any exception" and simply logs it. cheers James -- -- James Mills -- -- "Problems are solved by method"