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?

From Stephen Hansen <me@ixokai.io>
Newsgroups comp.lang.python
Subject Re: How much sanity checking is required for function inputs?
Date 2016-04-19 23:17 -0700
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>

Show all headers | 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