Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5091

Re: Overuse of try/except/else?

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 <prologic@shortcircuit.net.au>
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 <iqa1fd$4l0$1@dont-email.me> <BANLkTi=Gx=3G+QXwVB1Ls205os+cPdCXLA@mail.gmail.com> <4DC90692.50903@sequans.com>
From James Mills <prologic@shortcircuit.net.au>
Date Wed, 11 May 2011 13:37:57 +1000
Subject Re: Overuse of try/except/else?
To python list <python-list@python.org>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1391.1305085100.9059.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Tue, May 10, 2011 at 7:34 PM, Jean-Michel Pichavant
<jeanmichel@sequans.com> 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"

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Overuse of try/except/else? "Kyle T. Jones" <onexpadREMOVE@EVOMERyahoodotyouknow.com> - 2011-05-09 19:40 -0500
  Re: Overuse of try/except/else? James Mills <prologic@shortcircuit.net.au> - 2011-05-10 11:09 +1000
  Re: Overuse of try/except/else? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-05-10 11:34 +0200
  Re: Overuse of try/except/else? Adam Tauno Williams <awilliam@whitemice.org> - 2011-05-10 07:36 -0400
    Re: Overuse of try/except/else? Hans Georg Schaathun <hg@schaathun.net> - 2011-05-10 13:10 +0100
  Re: Overuse of try/except/else? Paul Probert <paulprobert@sbcglobal.net> - 2011-05-10 22:26 -0500
  Re: Overuse of try/except/else? James Mills <prologic@shortcircuit.net.au> - 2011-05-11 13:37 +1000
  Re: Overuse of try/except/else? Daniel Kluev <dan.kluev@gmail.com> - 2011-05-22 00:33 +1100

csiph-web