Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'read.': 0.03; 'compiler': 0.07; 'ugly': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'chained': 0.16; 'notation,': 0.16; 'operands': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'wrote:': 0.18; 'first.': 0.19; 'example': 0.22; 'putting': 0.22; 'header:User-Agent:1': 0.23; 'math': 0.24; "i've": 0.25; 'switch': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; "i'm": 0.30; 'assert': 0.31; 'bunch': 0.31; 'constant': 0.31; "can't": 0.35; 'done': 0.36; 'convention': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'easy': 0.60; 'received:173': 0.61; 'you.': 0.62; 'smith': 0.68; 'article': 0.77; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Jan Reedy Subject: Re: Comparison Style Date: Sat, 27 Apr 2013 17:40:46 -0400 References: <125c8f33-1a62-4dc0-9341-a2d8f7b58058@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1367098839 news.xs4all.nl 15978 [2001:888:2000:d::a6]:50375 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44455 On 4/27/2013 5:03 PM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> If you switch the order of operands in that, the compiler won't help >> you. Plus it "reads" wrong. So the convention is still >> variable==constant. > > I just found a nice example of putting the constant first. I've just > done a whole bunch of ugly math to find some slice limits. To make sure > they're sane, I'm writing: > > assert 5 <= i < j < original_song_count > > I can't think of any way to write that which would be as clean and easy > to read. Chained comparisons like this are standard math notation, which is why Python 'does the right thing' with them.