Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'binary': 0.05; 'builtin': 0.07; 'exception.': 0.07; 'raises': 0.07; 'subject:code': 0.07; 'bool': 0.09; 'indeed,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; '"and"': 0.16; 'chained': 0.16; 'comparisons,': 0.16; 'message-id:@dough.gmane.org': 0.16; 'operation.': 0.16; 'overloaded': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'statement.': 0.16; 'true:': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'saying': 0.18; 'default,': 0.22; 'sorry,': 0.22; 'flexibility': 0.23; "python's": 0.23; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'am,': 0.27; 'possibly': 0.27; 'in.': 0.27; 'header:X-Complaints-To:1': 0.28; '"in': 0.29; 'comparison': 0.29; 'included': 0.29; 'fri,': 0.30; 'sense': 0.31; '(and': 0.32; 'to:addr:python-list': 0.33; 'equal': 0.33; 'described': 0.35; 'false': 0.35; 'pm,': 0.35; 'add': 0.36; 'received:org': 0.36; 'really': 0.36; 'anything': 0.36; 'should': 0.36; 'ok,': 0.37; 'usual': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'most': 0.61; 'behavior': 0.64; 'jul': 0.65; 'surprise': 0.65; 'potentially': 0.66; 'believe': 0.69; "'and'": 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: code review Date: Sat, 14 Jul 2012 16:42:17 -0400 References: <4ff0f8e0$0$29988$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; 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:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: 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: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342298574 news.xs4all.nl 6978 [2001:888:2000:d::a6]:48603 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25320 On 7/14/2012 5:26 AM, Ian Kelly wrote: > On Fri, Jul 13, 2012 at 5:09 PM, Terry Reedy wrote: >> I believe the following rule is true: if a op b is True or False raises, Sorry, left out 'or' in 'or raises' > > I don't follow. Raises what? an Exception. >> 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 OK, add 'by default, without over-rides ;-). or 'for builtin classes'. Python's flexibility makes it really hard to make any general statement. In my book-in-progress, I am currently resorting to saying "In Python*, ..." whenever I know and remember that it is possibly to over-ride the customary behavior described in '...'. -- Terry Jan Reedy