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


Groups > comp.lang.python > #5045

Re: Overuse of try/except/else?

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 <prologic@shortcircuit.net.au>
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 <iqa1fd$4l0$1@dont-email.me>
References <iqa1fd$4l0$1@dont-email.me>
From James Mills <prologic@shortcircuit.net.au>
Date Tue, 10 May 2011 11:09:01 +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.1365.1304989764.9059.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

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