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


Groups > comp.lang.python > #97268

Re: Check if a given value is out of certain range

Path csiph.com!news.swapon.de!newsreader4.netcologne.de!news.netcologne.de!bcyclone01.am1.xlned.com!bcyclone01.am1.xlned.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status UNSURE 0.203
X-Spam-Level **
X-Spam-Evidence '*H*': 0.60; '*S*': 0.00; '(except': 0.05; 'english,': 0.09; 'preferable': 0.09; 'wed,': 0.15; 'boolean': 0.16; 'hand?': 0.16; 'imo,': 0.16; 'parentheses': 0.16; 'readable': 0.16; 'wrote:': 0.16; 'nested': 0.18; '>>>': 0.20; '2015': 0.20; "aren't": 0.22; 'sep': 0.22; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'error': 0.27; 'message- id:@mail.gmail.com': 0.27; 'correct': 0.28; 'function': 0.28; 'about.': 0.29; 'equally': 0.29; 'raise': 0.29; 'typically': 0.29; 'that.': 0.30; 'you?': 0.30; 'error.': 0.31; 'especially': 0.32; 'language.': 0.32; 'problem': 0.33; 'case,': 0.34; 'correctly': 0.34; 'gets': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'being': 0.37; 'say': 0.37; 'thought': 0.37; 'things': 0.38; 'no,': 0.38; 'drop': 0.38; 'why': 0.39; 'does': 0.39; 'unable': 0.39; 'easily': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'your': 0.60; 'avoid': 0.61; 'personally': 0.61; '30,': 0.63; 'relatively': 0.63; 'more': 0.63; 'between': 0.65; 'brain': 0.66; 'difficulty': 0.66; "they're": 0.66; '(is': 0.84; 'compose': 0.84; 'conditions,': 0.84; 'function)': 0.84; 'maths': 0.84; 'mirrors': 0.84; 'subject:value': 0.84; 'to:name:python': 0.84; '(ii)': 0.91; 'edwards': 0.91; 'prone': 0.91; 'subject:Check': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=u4Y7g5EN1SbCUqmc+ce2kq0ivvQfK52RMi+l1CRdYzg=; b=1H0OQRGthbmRXL4nZSTPa3n79LDYmlpYY1j/CcG1M3sCubdd9ORQsC1L0SUmWVy0Fv 0xMBFJzkIIWDpgbJzCWp2h1jnhDqaNy2wRqHx31T5wjUVMnx5zxO/NtkgTU/wfvmTuKS joCmdLy/U9UjU6OaclSY7mUyTlba5scujITorNPrDwCiAAS0hTZFX89HDFKyaSlXMUar 8CKShD2K763giGUZMjgajDUCTVYX73AVEYzuQ14g7b1NSqxjcro4xTybvHQzSQ/JbjsL i3Qvw07qVaQktikyb4fyTKQ++Ltda1tn9sJQ+vlXaebjYnZqaCSs+8tds+ZbAQ8rvd00 iVDw==
X-Received by 10.129.101.11 with SMTP id z11mr4906671ywb.85.1443646047971; Wed, 30 Sep 2015 13:47:27 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <muhg4j$70q$1@speranza.aioe.org>
References <mailman.229.1443511549.28679.python-list@python.org> <muefce$ia9$1@dont-email.me> <mueshe$9f0$1@ger.gmane.org> <mailman.252.1443578914.28679.python-list@python.org> <mugaov$79k$1@speranza.aioe.org> <muh0nf$jr0$1@reader1.panix.com> <87si5v3hpx.fsf@elektro.pacujo.net> <muhg4j$70q$1@speranza.aioe.org>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 30 Sep 2015 14:46:48 -0600
Subject Re: Check if a given value is out of certain range
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-Mailman-Approved-At Thu, 01 Oct 2015 09:18:58 +0200
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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>
Newsgroups comp.lang.python
Message-ID <mailman.284.1443683939.28679.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1443683939 news.xs4all.nl 23819 [2001:888:2000:d::a6]:42230
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 5776
X-Received-Body-CRC 1119571348
Xref csiph.com comp.lang.python:97268

Show key headers only | View raw


On Wed, Sep 30, 2015 at 2:19 PM, alister
<alister.nospam.ware@ntlworld.com> wrote:
> On Wed, 30 Sep 2015 21:06:02 +0300, Marko Rauhamaa wrote:
>
>> Grant Edwards <invalid@invalid.invalid>:
>>
>>>   not (0 <= x <= 10)         (I)
>>> [...]
>>>    (x < 0) or (x > 10)       (II)
>>> [...]
>>> IMO, (I) is _more_ readable than (II)
>>
>> IMO, they're equally readable (except that you should drop the redundant
>> parentheses from (II)).
>>
>>
>> Marko
>
> both are correct
> the problem with 1 is the human brain is not particularity good with
> negatives*.
> to do not (some function) you first of all have to work out some function
> & then invert it, a computer does this without difficulty the human brain
> gets confused which is why I personally consider ii is  more readable
> (YMMV especially if you are working with Boolean maths regularly) this
> example is relatively simple as things get more complex they become more
> error prone error.

To me, the negative of one condition (is x in this range) is more
easily processable than the disjunction of two conditions that
together compose the real, more easily understood condition (is x
outside this range). I find it preferable to avoid nested conditions,
not negated conditions, and (II) has more nesting than (I).

Thought mirrors language. In English, we typically would say "x is not
between 0 and 10", not "x is either less than 0 or greater than 10".

> *as an example you brain cannot correctly process the following.
>
> Not (think of your left toe)
>
> you are now thinking about it aren't you?

No, it made me think about thinking. I barely even registered the
phrase "left toe", much less thought about that.

In any case, that's more an issue of being unable to control what
you're thinking about. If I instruct you, "don't raise your right
hand", do you then automatically raise your right hand?

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


Thread

Re: Check if a given value is out of certain range Rob Gaddi <rgaddi@technologyhighland.invalid> - 2015-09-29 16:48 +0000
  Re: Check if a given value is out of certain range Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-29 21:32 +0100
    Re: Check if a given value is out of certain range sohcahtoa82@gmail.com - 2015-09-30 11:31 -0700
      Re: Check if a given value is out of certain range Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-30 23:31 +0100
        Re: Check if a given value is out of certain range Steven D'Aprano <steve@pearwood.info> - 2015-10-02 04:18 +1000
          Re: Check if a given value is out of certain range John Gordon <gordon@panix.com> - 2015-10-01 18:20 +0000
            Re: Check if a given value is out of certain range Steven D'Aprano <steve@pearwood.info> - 2015-10-02 05:19 +1000
              Re: Check if a given value is out of certain range John Gordon <gordon@panix.com> - 2015-10-01 19:41 +0000
                Re: Check if a given value is out of certain range Marko Rauhamaa <marko@pacujo.net> - 2015-10-01 22:59 +0300
                Re: Check if a given value is out of certain range Emile van Sebille <emile@fenx.com> - 2015-10-01 13:15 -0700
                Re: Check if a given value is out of certain range John Gordon <gordon@panix.com> - 2015-10-01 21:45 +0000
                Re: Check if a given value is out of certain range Ian Kelly <ian.g.kelly@gmail.com> - 2015-10-01 16:03 -0600
                Re: Check if a given value is out of certain range Chris Kaynor <ckaynor@zindagigames.com> - 2015-10-01 15:48 -0700
                Re: Check if a given value is out of certain range Ian Kelly <ian.g.kelly@gmail.com> - 2015-10-01 16:01 -0600
                Re: Check if a given value is out of certain range Steven D'Aprano <steve@pearwood.info> - 2015-10-03 20:29 +1000
                Re: Check if a given value is out of certain range Bartc <bc@freeuk.com> - 2015-10-03 11:48 +0100
                Re: Check if a given value is out of certain range Laura Creighton <lac@openend.se> - 2015-10-03 14:12 +0200
                Re: Check if a given value is out of certain range Steven D'Aprano <steve@pearwood.info> - 2015-10-03 23:51 +1000
                Re: Check if a given value is out of certain range wxjmfauth@gmail.com - 2015-10-03 07:19 -0700
                Re: Check if a given value is out of certain range Steven D'Aprano <steve@pearwood.info> - 2015-10-05 00:47 +1100
                Re: Check if a given value is out of certain range Rustom Mody <rustompmody@gmail.com> - 2015-10-04 19:28 -0700
                Re: Check if a given value is out of certain range Rustom Mody <rustompmody@gmail.com> - 2015-10-04 19:32 -0700
                Re: Check if a given value is out of certain range Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-10-03 11:49 -0400
          Re: Check if a given value is out of certain range Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-10-02 00:34 +0100
      Re: Check if a given value is out of certain range Michiel Overtoom <motoom@xs4all.nl> - 2015-10-05 10:18 +0200
        Re: Check if a given value is out of certain range Jussi Piitulainen <harvesting@makes.email.invalid> - 2015-10-05 13:08 +0300
          Re: Check if a given value is out of certain range Marko Rauhamaa <marko@pacujo.net> - 2015-10-05 14:42 +0300
            Re: Check if a given value is out of certain range Chris Angelico <rosuav@gmail.com> - 2015-10-06 00:10 +1100
              Re: Check if a given value is out of certain range Marko Rauhamaa <marko@pacujo.net> - 2015-10-05 16:25 +0300
      Re: Check if a given value is out of certain range Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-10-05 10:19 +0100
  Re: Check if a given value is out of certain range Random832 <random832@fastmail.com> - 2015-09-29 17:04 -0400
    Re: Check if a given value is out of certain range Luca Menegotto <otlucaDELETE@DELETEyahoo.it> - 2015-09-30 07:57 +0200
  Re: Check if a given value is out of certain range Emile van Sebille <emile@fenx.com> - 2015-09-29 14:07 -0700
  Re: Check if a given value is out of certain range Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-29 15:07 -0600
    Re: Check if a given value is out of certain range Steven D'Aprano <steve@pearwood.info> - 2015-09-30 11:55 +1000
      Re: Check if a given value is out of certain range Random832 <random832@fastmail.com> - 2015-09-29 23:08 -0400
        Re: Check if a given value is out of certain range Steven D'Aprano <steve@pearwood.info> - 2015-09-30 13:14 +1000
          Re: Check if a given value is out of certain range Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-29 23:54 -0600
  Re: Check if a given value is out of certain range Tim Chase <python.list@tim.thechases.com> - 2015-09-29 18:44 -0500
    Re: Check if a given value is out of certain range alister <alister.nospam.ware@ntlworld.com> - 2015-09-30 09:41 +0000
      Re: Check if a given value is out of certain range John Gordon <gordon@panix.com> - 2015-09-30 15:42 +0000
      Re: Check if a given value is out of certain range Grant Edwards <invalid@invalid.invalid> - 2015-09-30 15:56 +0000
        Re: Check if a given value is out of certain range Marko Rauhamaa <marko@pacujo.net> - 2015-09-30 21:06 +0300
          Re: Check if a given value is out of certain range alister <alister.nospam.ware@ntlworld.com> - 2015-09-30 20:19 +0000
            Re: Check if a given value is out of certain range Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-30 14:46 -0600
              Re: Check if a given value is out of certain range alister <alister.nospam.ware@ntlworld.com> - 2015-10-01 08:33 +0000
                Re: Check if a given value is out of certain range Chris Angelico <rosuav@gmail.com> - 2015-10-01 18:37 +1000
                Re: Check if a given value is out of certain range alister <alister.nospam.ware@ntlworld.com> - 2015-10-01 08:48 +0000
                Re: Check if a given value is out of certain range Ian Kelly <ian.g.kelly@gmail.com> - 2015-10-01 08:14 -0600
              Re: Check if a given value is out of certain range Steven D'Aprano <steve@pearwood.info> - 2015-10-02 04:59 +1000
            Re: Check if a given value is out of certain range Laura Creighton <lac@openend.se> - 2015-10-01 09:40 +0200
            Re: Check if a given value is out of certain range Laura Creighton <lac@openend.se> - 2015-10-01 09:58 +0200

csiph-web