Path: csiph.com!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!takemy.news.telefonica.de!telefonica.de!newsfeed.xs4all.nl!newsfeed7.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'expressions': 0.07; 'puts': 0.07; 'message-id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'thu,': 0.15; '"x"': 0.16; '>in': 0.16; '>to': 0.16; 'chained': 0.16; 'comparison.': 0.16; 'itself;': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'swaps': 0.16; "wouldn't": 0.16; 'comparing': 0.18; 'url:home': 0.18; 'variable': 0.18; '2015': 0.20; 'constant': 0.22; 'latter': 0.22; 'code.': 0.23; 'consistent': 0.23; 'second': 0.24; 'header:X-Complaints-To:1': 0.26; '+0000': 0.27; 'looks': 0.29; 'code': 0.30; 'gives': 0.35; "isn't": 0.35; 'visual': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'mean': 0.38; 'test': 0.39; 'to:addr:python.org': 0.40; 'john': 0.61; 'more': 0.63; 'sample': 0.63; 'natural': 0.67; '(utc),': 0.84; 'subject:value': 0.84; 'dennis': 0.91; 'received:108': 0.93; 'subject:Check': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Check if a given value is out of certain range Date: Sat, 03 Oct 2015 11:49:53 -0400 Organization: IISS Elusive Unicorn References: <560d78e2$0$1618$c3e8da3$5496439d@news.astraweb.com> <560d8726$0$1602$c3e8da3$5496439d@news.astraweb.com> <87r3le1ht3.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 108.68.178.61 X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1443887407 news.xs4all.nl 23839 [2001:888:2000:d::a6]:60614 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:97381 On Thu, 1 Oct 2015 21:45:46 +0000 (UTC), John Gordon declaimed the following: >In <87r3le1ht3.fsf@elektro.pacujo.net> Marko Rauhamaa writes: > >> Wouldn't > >> x < 0 or 10 < x > >> be even more visual? > >I don't know what you mean by "more visual". > >In my opinion, when comparing a variable to a constant, it's more natural >to have the variable on the left and the constant on the right, so that's >one strike against this code. > >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. To me, the above sample looks "right"... It is a test that "x is outside" the range 0..10, so surrounding the range with "x" gives that visual impression. While the "0 or 10" may be less pleasing than the "x is inside" a range (0 < x < 10), if one did not have chained expressions the latter would become "0 < x and x < 10". -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/