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


Groups > comp.lang.python > #107540

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 06:40:31 +0000
Lines 39
Message-ID <mailman.30.1461480050.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> <CAGgTfkNz5aeS5Jo+3yc+nWjUKnfhe=0zBVNeNHUMHD6Uj9VyEA@mail.gmail.com> <571C2541.9050309@icloud.com> <571C30C8.5000208@gmail.com> <mailman.24.1461465315.32212.python-list@python.org> <571c5e72$0$1615$c3e8da3$5496439d@news.astraweb.com> <CAGgTfkOXzfdASq7h4+0n3wokpmQmTREZ7Kzd_Qbog-hZ5HM7MA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 5cO02n/08HZVmCPXIdhvFghCQD42oi3MuEX+qYkcCxMw==
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.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'bug.': 0.07; 'classes.': 0.07; 'subject:How': 0.09; 'backwards': 0.09; 'globals': 0.09; 'python': 0.10; 'interpreter': 0.15; 'variables': 0.15; '2016': 0.16; '24,': 0.16; 'distinct': 0.16; 'object).': 0.16; 'pythonic': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'singleton': 0.16; 'storing': 0.16; 'subject:required': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.16; 'instance,': 0.18; 'library,': 0.18; '&gt;': 0.18; 'library': 0.20; 'to:2**1': 0.21; '(the': 0.22; 'not,': 0.22; 'mixed': 0.22; 'header:In-Reply-To:1': 0.24; 'feature': 0.24; 'sort': 0.25; 'module': 0.25; 'script': 0.25; 'example': 0.26; 'least': 0.27; 'message-id:@mail.gmail.com': 0.27; "we're": 0.30; 'probably': 0.31; 'run': 0.33; 'michael': 0.33; "d'aprano": 0.33; 'programming,': 0.33; 'steven': 0.33; 'running': 0.34; 'that,': 0.34; 'skip:& 20': 0.35; 'received:google.com': 0.35; 'expected': 0.35; 'but': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'depends': 0.36; 'modules': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'client': 0.37; 'aspects': 0.37; 'received:209': 0.38; 'shared': 0.38; 'application': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'still': 0.40; 'some': 0.40; 'your': 0.60; 'behavior': 0.61; "you'll": 0.61; 'clients': 0.61; 'more': 0.63; 'our': 0.64; 'sharing': 0.64; 'state.': 0.72; 'effectively,': 0.84; 'trickery': 0.84; 'subject:much': 0.91; 'processes,': 0.93
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=kJZVhY91vy3juYfsCQEtiv1AJrV7j508Qc0M0Yai5kQ=; b=eWM3YMWpfYk3g5/5kxZekK72saajFHKe3zKX0mh4eFV0TIWnB4VlO3h0K0oecbRO1d PV5kSrTMGs7Y0RdlWkWz1cS1jIuJRiBTcvGUJtuMK+4vNL2MfsiPNIEWAQO3/yFEcdUo CemK8K//alWxseFxP4Unntb6jYl2wW+ALkO8RghUNwkQwna6QZLVf9ltUFTym8yuR+vY txri3gue1gCiPtSm2inBe+jhz7EaiP/spN+UaxHP9VVZqKBvHpT7aLOXpwH3UAPW5oLt XDmcsDPMsiNMSdP17L0fW7fST8CeMff68ZjVMYYYUqaj46CRIdrK9sEj9uFSUMFrC9IA JImg==
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=kJZVhY91vy3juYfsCQEtiv1AJrV7j508Qc0M0Yai5kQ=; b=eJGo3xTHDKwugg8DbTfVIfiSCX5bdm+thz5Z4D2C1/bU60R6DGSfl6SKtEhiao06YG UpyMg3Z87fn1Sc6F4J/GPewj9Gyw5sKU6n1ajWlj4QcRqnjMyUabrOLzB4LRPGuPP0+I W6FblPrPvIBog8caca4RWZCAz+WcIO+KMKhHpRyWdCAyXNMpGzrdbY1Ds+6Iy6Qaetdi IsFGKkwoamPYYtQ9aNQNihLr3J2HdlJCPXZJiJJcx6xFIL2boUej5IEN8chxxfP1YIUp xMJ/kTylhW/Bc61faReu5+DYy+ldNlEWLddFlqT5cYZlBvnRAGPjskDm89Ni/HwYiJIV GeMw==
X-Gm-Message-State AOPr4FUc2n09+EJw4YN+1EoCwerBxinGYF4R7EEN96aNg2epJJ5zaLuKxbeWBbuVgxoT9dMZbtbHQKRVSucang==
X-Received by 10.140.253.84 with SMTP id y81mr4198500qhc.56.1461480042624; Sat, 23 Apr 2016 23:40:42 -0700 (PDT)
In-Reply-To <571c5e72$0$1615$c3e8da3$5496439d@news.astraweb.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 <CAGgTfkOXzfdASq7h4+0n3wokpmQmTREZ7Kzd_Qbog-hZ5HM7MA@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> <CAGgTfkNz5aeS5Jo+3yc+nWjUKnfhe=0zBVNeNHUMHD6Uj9VyEA@mail.gmail.com> <571C2541.9050309@icloud.com> <571C30C8.5000208@gmail.com> <mailman.24.1461465315.32212.python-list@python.org> <571c5e72$0$1615$c3e8da3$5496439d@news.astraweb.com>
Xref csiph.com comp.lang.python:107540

Show key headers only | View raw


On Sun, Apr 24, 2016, 1:51 AM Steven D'Aprano <steve@pearwood.info> wrote:

> On Sun, 24 Apr 2016 12:34 pm, Michael Torrie wrote:
>
> > There are many aspects to Pythonic programming, not just OOP.  For
> > example using modules to store shared state for your program components
> > is very pythonic, rather than using classes.  A module is kind of like a
> > singleton instance, and still is object-oriented by the way (the module
> > is an object).
>
> I find myself going backwards and forwards on whether or not that is a good
> idea. I think it depends on whether you are writing a library or an
> application.
>
> If you're writing an application, then storing state in module-level
> variables works fine. Your application is, effectively, a singleton, and if
> you try to run it twice, you'll (probably) be running it in two distinct
> processes, so that's okay.
>
> (If you're not, if somehow you perform some sort of trickery where you have
> a single Python interpreter running your script twice in the same process,
> then it will break horribly. But if you can do that, you're living on the
> edge already and can probably deal with it.)
>
> But if you're writing a library, then using module state is a Bad Idea.
> Your
> library may be used by more than one client in the same process, and they
> will conflict over each other's library-level state. "Global variables
> considered harmful."
>

I think we're giving mixed messages because we're conflating "constants"
and globals that are expected to change.

In our case here, I think two clients in the same process sharing state
might be a feature rather than a bug. Or at least it has the same behavior
as the current implementation.

>

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


Thread

Re: How much sanity checking is required for function inputs? Michael Torrie <torriem@gmail.com> - 2016-04-23 20:34 -0600
  Re: How much sanity checking is required for function inputs? Steven D'Aprano <steve@pearwood.info> - 2016-04-24 15:49 +1000
    Re: How much sanity checking is required for function inputs? Michael Selik <michael.selik@gmail.com> - 2016-04-24 06:40 +0000
      Re: How much sanity checking is required for function inputs? Steven D'Aprano <steve@pearwood.info> - 2016-04-25 04:00 +1000
        Re: How much sanity checking is required for function inputs? Michael Selik <michael.selik@gmail.com> - 2016-04-25 01:02 +0000

csiph-web