Path: csiph.com!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed8.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '16,': 0.03; 'essentially': 0.04; 'imply': 0.07; 'implies': 0.09; 'received:internal': 0.09; 'statements': 0.09; 'wed,': 0.15; 'thu,': 0.15; '"=="': 0.16; '"is"': 0.16; 'chained': 0.16; 'elements,': 0.16; 'equivalence': 0.16; 'expression.': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:66.111.4.27': 0.16; 'received:messagingengine.com': 0.16; 'received:out3-smtp.messagingengine.com': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; "shouldn't": 0.18; '2015': 0.20; 'saying': 0.22; 'sep': 0.22; 'am,': 0.23; 'tim': 0.24; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'compare': 0.27; 'comparison': 0.29; 'operators': 0.29; 'allows': 0.30; 'anywhere': 0.30; 'another': 0.32; 'point': 0.33; 'common': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'this?': 0.34; 'mix': 0.35; 'but': 0.36; 'there': 0.36; 'cases': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'really': 0.37; 'being': 0.37; 'agree': 0.37; 'thought': 0.37; 'received:66': 0.38; 'anything': 0.38; 'several': 0.38; 'to:addr:python.org': 0.40; 'still': 0.40; 'some': 0.40; 'relationship': 0.61; 'header:Message-Id:1': 0.61; 'between': 0.65; 'natural': 0.67; 'aspect.': 0.84; 'loses': 0.84; 'together,': 0.84; 'subject:True': 0.93; 'hand,': 0.97 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=6TZ7YpvZme6Wbt52z2iiT6cUdM4=; b=ts5gOo Y2whdteC7JKFPc0Gvqs94jinRz25aiGrW+Yw4qi9gAl0T2kW+q/DAQf8HrhCxPWA TFzsdtxVMq3Lv8RKsqyE7lIobo1hcAurJS2lL+nfIXNE4qcc23N+TSGQX9nqjIyw ZZAAgLe6ti8bX00ldIik9Njc+Wnxy1tYOUU7w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=6TZ7YpvZme6Wbt5 2z2iiT6cUdM4=; b=EciXVZVVH0D8/ZwJgUgkM89MLQb3qMNzDwhNMMMPrOKPnct ZUmKo1TcpnI+yhKVA3IuWrSW+5SHd1hXD8zDokST7lBDpg3UZXuMGjt3RoAIjmwJ V/ey5BK/xvDvIDTLiT9B0SFxxQh4EpV7WhJZ7pXnxxzsXi4RmUh9WUoHRts0= X-Sasl-Enc: 1Wg3N2zhZXBU88hHgXSQPEWbeacBZaDXgpjcC6HxgWT3 1442425012 From: Random832 To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-746d2121 Subject: Re: True == 1 weirdness Date: Wed, 16 Sep 2015 13:36:52 -0400 In-Reply-To: <55f9a5e9$0$1643$c3e8da3$5496439d@news.astraweb.com> References: <0b949fe0-09b4-46b0-b4ac-a85a9bfebfd5@googlegroups.com> <55f9a5e9$0$1643$c3e8da3$5496439d@news.astraweb.com> 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442425015 news.xs4all.nl 23778 [2001:888:2000:d::a6]:60974 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96697 On Wed, Sep 16, 2015, at 13:24, Steven D'Aprano wrote: > On Thu, 17 Sep 2015 12:03 am, Random832 wrote: > > if word in line in text: > print("word in line and line in text") > > But I agree with Tim Chase: I wouldn't use it, even though it's legal. I just had another thought on *why* the other cases make me so uneasy. The reason this is reasonable for simple cases like a > b > c or a < b <= c is that, in their normal meanings, these operations are transitive. a > b and b > c implies a > c. a < b and b <= c implies a < c. This is also a good reason for allowing "==" or "is" anywhere - because it's a natural way to write a graph including an equivalence class: a < b == c < d implies b < d, a < c, and a < d. So it's a natural way of writing it. On the other hand, a in b in c doesn't imply a in c for several common cases, and a > b < c doesn't imply anything about the relationship between a and c, so it really shouldn't be a single expression. A chained comparison doesn't *actually* compare non-adjacent elements, but with well-defined transitive relationships (or... semi-transitive? is there a word for this? My point being that when you include some == or mix <= and < together, it still allows you to make some statements about their relationships), you are essentially saying "a, b, c are ordered". The generalization to mixing arbitrary operators loses this aspect.