Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python,': 0.02; '[1]:': 0.09; '[2]:': 0.09; '[3]:': 0.09; 'merging': 0.09; 'works.': 0.09; 'python': 0.11; '[4]:': 0.16; 'kitchen': 0.16; 'means:': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'thu,': 0.19; 'header:User-Agent:1': 0.23; 'fine': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'skip:( 20': 0.30; '13,': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'writes:': 0.31; '"the': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'false': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'box,': 0.64; 'received:117': 0.78; 'message- id:@mx.google.com': 0.80; 'cupboard': 0.84; 'subject:gets': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; bh=1Nzamr8Yz6nraEUI/c2e9J1sFp/hZ3/4j1QwhvclSeE=; b=m0tmMhB/hI5a915Umey6R9VlCpjsAPrcocmSApQ3HWLFztRcGn/zdCHS368DZIZr0T KWfln1i1sw6e+qkIqGJASHocnU47frUvTo/PRNmpxxXOS5SdLfZ+HuIPmA9naKrkhqXh SjHgZemA6YjY0NbqvCn0ja29b2dIWuLA8uILs9PhnQ0rmGSyeDnYdCQO1H8E34cpveOq A/Iu+GHovLkbC62K3c3gaHsNU3LSPZS1Zd+DqDM8MJoxDGSiKwO7PYj5xkHeJycGxIPM YaUqhwiKzPB9ZsqlarTc2C7NqCQ/qb5X64TNMqoegbdZYA8nZeA6+QUtdbj7RZfsHD4Y TAhA== X-Received: by 10.68.136.3 with SMTP id pw3mr22637239pbb.2.1371098155783; Wed, 12 Jun 2013 21:35:55 -0700 (PDT) Sender: Kushal Kumaran From: Kushal Kumaran To: python-list@python.org Subject: Re: A certainl part of an if() structure never gets executed. In-Reply-To: References: <2bc90d3b-09c2-4315-9357-ff7f039465e0@googlegroups.com> <51b926a3$0$29997$c3e8da3$5496439d@news.astraweb.com> User-Agent: Notmuch/0.15.2+174~gb6d4402 (http://notmuchmail.org) Emacs/24.2.1 (x86_64-pc-linux-gnu) Date: Thu, 13 Jun 2013 10:05:50 +0530 MIME-Version: 1.0 Content-Type: text/plain 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371098165 news.xs4all.nl 15891 [2001:888:2000:d::a6]:42681 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47894 Chris Angelico writes: > On Thu, Jun 13, 2013 at 11:55 AM, Steven D'Aprano > wrote: >> In English: >> >> "the cat is in the box or the cupboard or the kitchen" >> >> means: >> >> "the cat is in the box, or the cat is in the cupboard, or the cat is in >> the kitchen". >> >> >> But that is not how Python works. In Python, you have to say: >> >> cat in box or cat in cupboard or cat in kitchen > > Or you can deem that there be one single location that is the merging > of box, cupboard, and kitchen, and say: > > cat in (box+cupboard+kitchen) > > which works fine for character-in-string and element-in-list searches. > hm... In [1]: s1 = 'abc' In [2]: s2 = 'def' In [3]: s3 = 'ghi' In [4]: 'cd' in s1 or 'cd' in s2 or 'cd' in s3 Out[4]: False In [5]: 'cd' in s1+s2+s3 Out[5]: True -- regards, kushal