Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'operator': 0.03; 'binary': 0.05; 'raises': 0.07; 'subject:code': 0.07; 'bool': 0.09; 'indeed,': 0.09; 'terry': 0.09; '"and"': 0.16; 'chained': 0.16; 'comparisons,': 0.16; 'operation.': 0.16; 'overloaded': 0.16; 'reedy': 0.16; 'sqlalchemy': 0.16; 'true:': 0.16; 'wether': 0.16; 'later': 0.16; 'wrote:': 0.17; 'regardless': 0.21; 'occurs': 0.22; 'header:In-Reply-To:1': 0.25; 'compiled': 0.27; 'in.': 0.27; 'message-id:@mail.gmail.com': 0.27; '>>>>': 0.29; 'comparison': 0.29; 'objects': 0.29; 'included': 0.29; 'fri,': 0.30; 'on,': 0.30; 'sense': 0.31; '(and': 0.32; 'not.': 0.32; 'to:addr:python- list': 0.33; 'equal': 0.33; 'received:google.com': 0.34; 'false': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'anything': 0.36; 'should': 0.36; '(for': 0.37; 'usual': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'most': 0.61; 'jul': 0.65; 'surprise': 0.65; 'potentially': 0.66; 'believe': 0.69; "'and'": 0.84 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=V40HAAuh65kfqPipomgtlhGsn54os8d56EQziPsjeXs=; b=iT11rx2SDV2zUHhVtdTOheZRJ98/jTes63mrobyL0+LOIBptwR4Ze3ehpSyA7LHBCi jARZ3qVF/4+oKLRQ2V+bWEqGqERZz1r3+5jR5gLD6+43xKEL+pzgCdgVLHQ3GNJB1tpG N6WSKJoy57sU4RukcnnK9inK134x6Zd0ukGAVCK0y7VrXFFdJLylwkaTGFqlxIb9zm7x wYTfe+KKIESdhliXr31da0FLbPTJCJLeeoqUNQUwU0bAAJZZbdQlqo8U3tdmurEtpmCS pBlgE+0IILxT7Xh8LQNdB6cvqpGrIRS7Deq4/6+DrwPqt+97F0EzLjio2QNBLF1gLEtV pRsQ== MIME-Version: 1.0 In-Reply-To: References: <4ff0f8e0$0$29988$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Sat, 14 Jul 2012 03:26:53 -0600 Subject: Re: code review To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342258047 news.xs4all.nl 6895 [2001:888:2000:d::a6]:41481 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25308 On Fri, Jul 13, 2012 at 5:09 PM, Terry Reedy wrote: > >> From now on, for each operator I would have to remember wether it >> is a supposedly comparison operator or not. > > > I believe the following rule is true: if a op b is True or False raises, I don't follow. Raises what? > then op is a potentially chained comparison operation. They are (not) equal > (and (not) is), the 4 order comparisons, and (not) in. 'in' should be the > only surprise and most confusing. >>>> 1 < 3 in {3,4} > True >>>> 3 in {3,4} < {4} > False > > 'and' and 'or' are not included because they do not always return a bool, > and indeed, they are not binary operators in the usual sense because of > short-circuiting. The only one of those operators that can be said to always return a bool is "is (not)". The others (apart from "and" and "or") all can be overloaded to return anything you want (for example, sqlalchemy overloads them to return expression objects that are later compiled into SQL), and chaining still occurs regardless of the types they are applied to.