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


Groups > comp.lang.python > #107526

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

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Michael Selik <michael.selik@gmail.com>
Newsgroups comp.lang.python
Subject Re: How much sanity checking is required for function inputs?
Date Sun, 24 Apr 2016 01:38:29 +0000
Lines 34
Message-ID <mailman.19.1461461927.32212.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> <57185E88.30201@yahoo.com> <57197FC3.4030701@icloud.com> <1461291613.433097.586174185.01BB7E37@webmail.messagingengine.com> <57199BA5.4000703@icloud.com> <1461302724.477236.586265777.181ACCA0@webmail.messagingengine.com> <571C21A3.5090507@icloud.com> <CAGgTfkPZZkKiMeS=2bke-qooGDC0_cegE2TDhiubPN4-nNmcZg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de km7YQzMGBrv6MU8Jg9iHXw4Qc9VDPjEyfiCQ0aZQzfjw==
Return-Path <michael.selik@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:How': 0.09; '16)': 0.09; 'dict': 0.09; 'occurrences': 0.09; 'python': 0.10; 'appropriate': 0.14; 'variables': 0.15; '2016': 0.16; '23,': 0.16; 'constants': 0.16; 'coordinates': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:required': 0.16; 'wrote:': 0.16; '&gt;': 0.18; 'variable': 0.18; 'to:2**1': 0.21; 'not,': 0.22; 'constant': 0.22; 'stephen': 0.22; 'file.': 0.22; 'code,': 0.23; 'seems': 0.23; 'bigger': 0.23; 'sat,': 0.23; 'header:In-Reply- To:1': 0.24; 'module': 0.25; 'message-id:@mail.gmail.com': 0.27; 'module.': 0.27; 'said,': 0.27; 'correct': 0.28; 'getting': 0.33; 'common': 0.33; 'editor': 0.34; 'file': 0.34; 'skip:& 20': 0.35; 'received:google.com': 0.35; 'text': 0.35; 'replace': 0.35; 'instead': 0.36; 'lines': 0.36; 'received:209.85': 0.36; 'projects.': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'skip:& 10': 0.37; 'agree': 0.37; 'list.': 0.37; 'things': 0.38; 'received:209': 0.38; 'received:209.85.220': 0.38; 'why': 0.39; 'easily': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'easy': 0.60; 'your': 0.60; 'share': 0.61; 'black': 0.61; 'here.': 0.62; 'making': 0.62; 'different': 0.63; 'positions': 0.64; 'wanting': 0.66; 'skip:\xc2 10': 0.67; 'color': 0.67; 'subject:much': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=OoZe7U/iCqhLX7eMtfNrpvXl9QCNxIW2+QPwTEiA6UA=; b=gLSvSMevG9iz2KyZ+2X5AqASFgvYVSPkEvM3qhJh8QOuhz+DBJ8VeKnXTpZr6xUFNF tJKnNtdbP9PssnuzEtOaQWckwCvpA9E1mxsiYeNjCfv55FkzADN+xoO2CRVWISwYwiRS qlgayqqBzVxOE1c9CUDwSGSQLMAxZsCBtFAmC2Mp569uebQ3GY8fUT7WCKnnfoE+2nLW z2SHUrblXV3rIzzUnBZB1xQ/99Of9PZzh+7E3FDeup9O8R8lTNlCMiriJ2YDTDdbs5Gu X9ikSE55/DlcfZoEYVIDwaSYt0uCD2c2N2855GWHMr6PuWRprX9+XR90kDN/cYVxAmTK O8/g==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=OoZe7U/iCqhLX7eMtfNrpvXl9QCNxIW2+QPwTEiA6UA=; b=U+iLn2276sP+WMJWkZ+wx5a48TcevKAckf+B8o8gj7zoa22tMm8VK7jgytRPQugtC5 yJQlbSbIHikrQ+DdE/+ZGF1LQtYF9CM/DwxyCgulJSQIwMGXvqqOBKTNYFgW/K7/+gj6 xTyaeIet69QZpxLy1xmlsg9qpj/pz4hENZAHwae/JCJo9hf01peYwEbpzNgWIZjjSdDg ftFTD2uTBl2m2CwCk4XT60IyW7zFtmHquqYp4bLS0B5Y+On7mILMXavIYu8S/gvurBgl itcmGHhTluMOnCZEV5JMfpgwSYmZrDouKiNhsydBSZ/bN9t75nVRnhcctQmiuvCXFPbH WIjA==
X-Gm-Message-State AOPr4FUubKK7XWaGnc5ilb/ffTGKL7H+iO2uAIkOAiRP+le8KXcsQnAXlknH5r/vffpzmbOrr1mIQ0a4dx77Hg==
X-Received by 10.55.151.199 with SMTP id z190mr11067842qkd.172.1461461919005; Sat, 23 Apr 2016 18:38:39 -0700 (PDT)
In-Reply-To <571C21A3.5090507@icloud.com>
X-Content-Filtered-By Mailman/MimeDel 2.1.22
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 <CAGgTfkPZZkKiMeS=2bke-qooGDC0_cegE2TDhiubPN4-nNmcZg@mail.gmail.com>
X-Mailman-Original-References <5713E52D.3060407@icloud.com> <1461131475.4042173.584042297.03DAB00E@webmail.messagingengine.com> <57171D23.40709@stoneleaf.us> <1461133057.4046578.584060569.2DD34821@webmail.messagingengine.com> <57185E88.30201@yahoo.com> <57197FC3.4030701@icloud.com> <1461291613.433097.586174185.01BB7E37@webmail.messagingengine.com> <57199BA5.4000703@icloud.com> <1461302724.477236.586265777.181ACCA0@webmail.messagingengine.com> <571C21A3.5090507@icloud.com>
Xref csiph.com comp.lang.python:107526

Show key headers only | View raw


On Sat, Apr 23, 2016 at 9:31 PM Christopher Reimer <
christopher_reimer@icloud.com> wrote:

> On 4/21/2016 10:25 PM, Stephen Hansen wrote:
> >
> > Why not, 'color in ("black", "white")'?
>
> Checkers seems popular around here. What if I want to change "white" to
> "red," as red and black is a common color scheme for checkers. Do I
> change a single constant variable or replace all the occurrences in the
> files?
>

Why so many files? Python can easily support thousands of lines in a file.
If it's just one file any text editor can do a quick find-replace.

That said, it's easy to make some global ``red = 'red'``.

Some of these constants are shortcuts. Instead of writing slice(0, 16)
> or slice(48, 64), and getting the two confused, I write
> const['board_bottom'] or const['board_top'], respectively, when I want
> to pull the correct set of positions from coordinates list.
>

Why hide these things in a dict ``const`` instead of just making them
top-level variables in the module themselves?  ``board_top = slice(48,
64)``

> That said, if you're wanting to share constants across different parts
> > of your code, use a module.
>

Or just use one file to keep things easier. But, yes, I agree a module of
constants is appropriate for bigger projects.

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


Thread

Re: How much sanity checking is required for function inputs? Michael Selik <michael.selik@gmail.com> - 2016-04-24 01:38 +0000

csiph-web