Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.055 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'operator': 0.03; 'think,': 0.05; 'puts': 0.07; 'thu,': 0.15; 'comparison.': 0.16; 'itself;': 0.16; 'set,': 0.16; 'swaps': 0.16; 'wrote:': 0.16; 'later': 0.16; "wouldn't": 0.16; 'variable': 0.18; '2015': 0.20; 'parse': 0.22; 'consistent': 0.23; 'second': 0.24; 'header:In-Reply-To:1': 0.24; 'chris': 0.26; 'mostly': 0.27; 'message-id:@mail.gmail.com': 0.27; 'transition': 0.27; 'argue': 0.29; 'consistency': 0.29; 'received:209.85.213.174': 0.29; 'second,': 0.29; 'code': 0.30; 'compared': 0.30; 'another': 0.32; 'especially': 0.32; 'received:google.com': 0.35; 'set.': 0.35; "isn't": 0.35; 'but': 0.36; 'lines': 0.36; 'received:209.85': 0.36; 'mode': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'thought': 0.37; 'received:209': 0.38; 'mean': 0.38; 'means': 0.39; 'does': 0.39; 'along': 0.39; 'easily': 0.39; 'takes': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'john': 0.61; 'more': 0.63; 'within': 0.64; 'between': 0.65; 'of:': 0.66; '(10': 0.84; 'have?': 0.84; 'sets,': 0.84; 'subject:value': 0.84; 'to:name:python': 0.84; 'subject:Check': 0.95; 'hand,': 0.97 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=OEKQB5nbWTq0IcokHGCvtFCiHvImsJ9oRT/1+XlzMpM=; b=bD1Kklm9J7UN88yP8aATLNWSVhnEupFG0PFXKT7TRpOE4NZe3ZWc2/XdyQ1/YUkeqg p/Xn2Kzfohfjg6fs9ZFhRTskaTNLj4rnnbRRXrPZYgq6SOgBfAvnB5HS5jDyZyQjrLx0 gaLJogqzrkaOWf0fmHCv5NbUjNzPVfHyO1UDZUXF+h8V2h6U7hih5L8106q+UepflGXf LXJOkwX6sCo6um7+sA/O4LfkFcbw6HM2p/wI4Ttn5/bnmm9/xuFZGJ1jWIJWC9Rgz0c+ 2w+y6KWjA7D/lacESNzbRBjBqsxFZDsxIn6IeXtCYfE8fiauBZeAXppToyIQyQxjnidZ S1Lw== X-Gm-Message-State: ALoCoQmio7RfKzlH46S/wv2GVr5foy42vuKmEQLt0gq/2Ap8Ehhn6EwljVcOU75dHOow8HRM4+7x X-Received: by 10.50.50.240 with SMTP id f16mr1345944igo.95.1443739735683; Thu, 01 Oct 2015 15:48:55 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> <560d8726$0$1602$c3e8da3$5496439d@news.astraweb.com> <87r3le1ht3.fsf@elektro.pacujo.net> From: Chris Kaynor Date: Thu, 1 Oct 2015 15:48:35 -0700 Subject: Re: Check if a given value is out of certain range To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1443742857 news.xs4all.nl 23854 [2001:888:2000:d::a6]:36921 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:97319 On Thu, Oct 1, 2015 at 3:03 PM, Ian Kelly wrote: > On Thu, Oct 1, 2015 at 3:45 PM, John Gordon wrote: > > In <87r3le1ht3.fsf@elektro.pacujo.net> Marko Rauhamaa writes: > >> Wouldn't > > > >> x < 0 or 10 < x > > > >> be even more visual? > > > > [SNIP] > > > > Another strike is that the code isn't consistent with itself; it puts the > > variable on the left in the first comparison, then swaps to the right for > > the second comparison. > > And on the other hand, it consistently uses the < operator rather > than swapping to > for the second comparison. I would argue that the former consistency is more important than the second, mostly because my mode of thought is along the lines of: - Do I have more than 10 apples? (x > 10) or - Do I have fewer than 10 apples? (x < 10) rather than - Is 10 fewer apples than I have? (10 < x) or - Is 10 more apples than I have? (10 > x) Because the former set is how I think, the former set is the easier to understand. By no means does it mean I cannot understand the later set, but it takes more thought to parse the meaning. If a bunch of code consistently used the second, my mind would adapt to more easily parse it, but it would take a while to transition between the sets, especially compared to transitioning within a set. Chris