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


Groups > comp.lang.python > #107398

Re: How much sanity checking is required for function inputs?

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Stephen Hansen <me@ixokai.io>
Newsgroups comp.lang.python
Subject Re: How much sanity checking is required for function inputs?
Date Tue, 19 Apr 2016 23:17:37 -0700
Lines 17
Message-ID <mailman.17.1461133060.12923.python-list@python.org> (permalink)
References <5713E52D.3060407@icloud.com> <1461131475.4042173.584042297.03DAB00E@webmail.messagingengine.com> <57171D23.40709@stoneleaf.us> <1461133057.4046578.584060569.2DD34821@webmail.messagingengine.com>
Mime-Version 1.0
Content-Type text/plain
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de ax9z2LyZmzJbbCFgkgAq8Q9fpAmFrz21zxlosOjAKfow==
Return-Path <me@ixokai.io>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:How': 0.09; 'meaningful': 0.09; 'received:internal': 0.09; 'yeah,': 0.09; 'exception': 0.13; 'appropriate': 0.14; '(usually)': 0.16; '--s': 0.16; '11:09': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'subject:required': 0.16; 'wrote:': 0.16; 'library': 0.20; 'meant': 0.22; 'exceptions': 0.22; 'stephen': 0.22; '(or': 0.23; 'needed.': 0.23; 'header:In-Reply-To:1': 0.24; 'error': 0.27; '(such': 0.27; 'code': 0.30; 'largely': 0.33; 'tue,': 0.34; 'generic': 0.35; 'level': 0.35; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'doing': 0.38; 'received:66': 0.38; 'to:addr:python.org': 0.40; 'where': 0.40; 'header:Message-Id:1': 0.61; 'more': 0.63; 'informative,': 0.84; 'ethan': 0.91; 'furman': 0.91; 'subject:much': 0.91
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=ixokai.io; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=9shp3PV064x2oaZ2lU23E6c2KHA=; b=l4zTYk OzjXTk4Kbbxt4yh2q/+Ag9RyQZhngpdgbsLDD/bRTcRBiZFqu4ww5l3l6MwUXHqY cNjalitjpnf+v6HOHwp7bvIhFX+IabAaDWw2n4UjMDcFAisrtiZQmZnyn0XlYyNO NQRxEhRDrdTiLgfuk0q/mmHZZKskSCGPcSGRE=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=9shp3PV064x2oaZ 2lU23E6c2KHA=; b=alpwhgrgs13yY+7ccMHx7yBstT0+mVN6LvvqK1wcHHtueZL 0DVOzuS+r1KIe7w7r3T4LukozIvrAyhJlKNIzKJw7FSAopfrr1RaOKZ3vaQSWFdV ObEF7yFB0WSyFFQf6kd2PP4mTEm8XpeKqy2ENCmEK9x0J96wSwXKpMpw92HY=
X-Sasl-Enc zyMlx8/dVB8KKeonEAT/pixojq6Wp4ioktKEtTq44rSf 1461133057
X-Mailer MessagingEngine.com Webmail Interface - ajax-9b739787
In-Reply-To <57171D23.40709@stoneleaf.us>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <1461133057.4046578.584060569.2DD34821@webmail.messagingengine.com>
X-Mailman-Original-References <5713E52D.3060407@icloud.com> <1461131475.4042173.584042297.03DAB00E@webmail.messagingengine.com> <57171D23.40709@stoneleaf.us>
Xref csiph.com comp.lang.python:107398

Show key headers only | View raw


On Tue, Apr 19, 2016, at 11:09 PM, Ethan Furman wrote:
> On 04/19/2016 10:51 PM, Stephen Hansen wrote:
> > I use 1) more to be less 'nicer' and more, er, 'more specific'. Since I
> > don't like exceptions to rise to the user level where niceness is
> > needed.
> 
> Yeah, that's a better phrasing for (1); I meant more appropriate or 
> informative, such as swapping an internal error (such as KeyError) for a 
> more meaningful FieldNotFound error (or whatever) -- largely library 
> code concerns.

Yeah, and what the OP is doing is going the exact opposite-- from a
more-specific exception (KeyError) to a more generic one (Exception).

To me that's (usually) an anti-pattern. 

--S

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


Thread

Re: How much sanity checking is required for function inputs? Stephen Hansen <me@ixokai.io> - 2016-04-19 23:17 -0700

csiph-web