Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107240
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Newsgroups | comp.lang.python |
| Subject | Re: How much sanity checking is required for function inputs? |
| Date | Sun, 17 Apr 2016 22:26:21 -0700 |
| Lines | 34 |
| Message-ID | <mailman.138.1460957122.6324.python-list@python.org> (permalink) |
| References | <5713E52D.3060407@icloud.com> <57146FFD.4090204@stoneleaf.us> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de W3sELp4emmAeMvLdO7rgwAubC1MVJWkeFBMzkV1OnSFg== |
| Return-Path | <ethan@stoneleaf.us> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'error:': 0.05; 'sanity': 0.07; 'subject:How': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'python': 0.10; '(tm)': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:required': 0.16; 'wrote:': 0.16; 'python?': 0.18; 'bug?': 0.22; 'keyerror:': 0.22; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'error': 0.27; 'checking': 0.27; '---': 0.28; 'checking.': 0.29; '~ethan~': 0.29; 'raise': 0.29; 'checks': 0.30; 'point': 0.33; 'apply,': 0.33; 'traceback': 0.33; 'too': 0.36; 'to:addr:python- list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'turn': 0.37; 'things': 0.38; 'skip:v 20': 0.38; 'wrong': 0.38; 'anything': 0.38; 'data': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'close': 0.61; 'charset:windows-1252': 0.62; 'color': 0.67; 'you:': 0.79; 'reasons:': 0.84; 'subject:much': 0.91 |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
| In-Reply-To | <5713E52D.3060407@icloud.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| 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 | <57146FFD.4090204@stoneleaf.us> |
| X-Mailman-Original-References | <5713E52D.3060407@icloud.com> |
| Xref | csiph.com comp.lang.python:107240 |
Show key headers only | View raw
On 04/17/2016 12:34 PM, Christopher Reimer wrote:
> How much sanity checking is too much in Python?
What happens if your extensive sanity checks turn up a bug?
In Python the usual answer is you raise an error:
raise ValueError('blahblah not a valid color')
What happens if you don't sanity check anything and the wrong color is
passed in?
Python will raise an error for you:
Traceback
...
KeyError: 'blahblah' not found
---
I sanity check for three reasons:
1) raise a nicer error message
2) keep the point of failure close to the error
3) the consequences of bad data are Bad Bad Things (tm)
If none of those apply, I don't bother sanity checking.
--
~Ethan~
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How much sanity checking is required for function inputs? Ethan Furman <ethan@stoneleaf.us> - 2016-04-17 22:26 -0700
csiph-web