Path: csiph.com!news.mixmin.net!feeds.phibee-telecom.net!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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; 'that?': 0.05; 'elegant': 0.07; 'brackets': 0.09; 'git': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; ':-)': 0.12; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.16; 'language': 0.19; '>>>': 0.20; '2015': 0.20; 'lawrence': 0.22; 'parse': 0.22; 'sep': 0.22; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'example': 0.26; 'header:X-Complaints-To:1': 0.26; 'figure': 0.27; 'read,': 0.29; 'certain': 0.31; 'language.': 0.32; 'similar': 0.33; 'tue,': 0.34; 'there': 0.36; 'week.': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'hi,': 0.38; 'to:addr:python.org': 0.40; 'mark': 0.40; 'easy': 0.60; 'email addr:gmail.com': 0.62; 'charset:windows-1252': 0.62; 'within': 0.64; 'our': 0.64; 'between': 0.65; 'day': 0.67; 'counts': 0.81; 'old,': 0.83; 'pythonistas,': 0.84; 'subject:value': 0.84; 'ten,': 0.84; 'utc-7,': 0.84; 'subject:Check': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Check if a given value is out of certain range Date: Wed, 30 Sep 2015 23:31:59 +0100 References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 195.147.66.69 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 In-Reply-To: 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1443652357 news.xs4all.nl 23720 [2001:888:2000:d::a6]:55443 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:97260 On 30/09/2015 19:31, sohcahtoa82@gmail.com wrote: > On Tuesday, September 29, 2015 at 1:33:23 PM UTC-7, Mark Lawrence wrote: >> On 29/09/2015 17:48, Rob Gaddi wrote: >>> On Tue, 29 Sep 2015 10:16:04 +0530, Laxmikant Chitare wrote: >>> >>>> Hi, >>>> >>>> I know there is an elegant way to check if a given value is within >>>> certain range. >>>> Example - To check if x is between zero and ten, I can do 0 < x 10. >>>> >>>> Is there any similar elegant way to check if a value is out of certain >>>> range? >>>> Example - To check if x is either less than zero or greater than ten? >>>> Right now I am using x < 0 or x > 10. >>>> >>>> Regards, >>>> Laxmikant >>> >>> not (0 <= x <= 10) >>> >> >> Yuck. >> >> -- >> My fellow Pythonistas, ask not what our language can do for you, ask >> what you can do for our language. >> >> Mark Lawrence > > What is so "yuck" about that? What would you do instead? It seems like the best solution to me. Easy to read, fast to execute. > I have to parse those damn brackets and then figure out the inverted logic. Give me x < 0 or x > 10 any day of the week. When you're an old, senile git like me, readability counts :-) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence