Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4830

Re: if statement multiple or

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <mail@timgolden.me.uk>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'though.': 0.07; 'python': 0.07; 'from:addr:timgolden.me.uk': 0.09; 'from:name:tim golden': 0.09; 'message-id:@timgolden.me.uk': 0.09; '>>>': 0.12; 'am,': 0.14; 'wrote:': 0.14; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'method.': 0.19; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'header:In-Reply-To:1': 0.22; 'cc:addr:python-list': 0.22; "i'm": 0.26; 'thanks': 0.29; "won't": 0.30; 'cc:addr:python.org': 0.31; 'strings,': 0.31; 'tjg': 0.31; "i've": 0.33; 'test': 0.33; 'using': 0.34; 'received:192': 0.34; 'christian': 0.35; 'print': 0.35; 'header :User-Agent:1': 0.35; 'case,': 0.36; 'received:192.168': 0.37; 'could': 0.39; 'sets': 0.40; 'would': 0.40; "it's": 0.40; 'from:addr:mail': 0.60; 'as:': 0.64; 'special': 0.66; 'schrieb': 0.84; 'to:none': 0.92
Date Fri, 06 May 2011 14:31:41 +0100
From Tim Golden <mail@timgolden.me.uk>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10
MIME-Version 1.0
CC python-list@python.org
Subject Re: if statement multiple or
References <BANLkTinSHanse0mgUJVsUZ_6nHh5zLjbUw@mail.gmail.com> <mailman.1236.1304679638.9059.python-list@python.org> <9e36f9bc-0009-4924-9b36-62438bd52399@k22g2000yqh.googlegroups.com> <mailman.1242.1304684741.9059.python-list@python.org> <67941d2c-ad97-4395-80b9-59e8c941df99@w21g2000yqm.googlegroups.com>
In-Reply-To <67941d2c-ad97-4395-80b9-59e8c941df99@w21g2000yqm.googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1247.1304688706.9059.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 82.94.164.166
X-Trace 1304688706 news.xs4all.nl 41113 [::ffff:82.94.164.166]:59150
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:4830

Show key headers only | View raw


On 06/05/2011 14:17, scattered wrote:
> On May 6, 8:25 am, Christian Heimes<li...@cheimes.de>  wrote:
>> Am 06.05.2011 14:09, schrieb scattered:
>>
>>> sets could also work
>>
>>> if set('abc')&  set(line) == set():
>>>       print line
>>
>> Right!
>> Sets work in this special case, because the OP just wants to search for
>> a single char. It won't work for longer strings, though.
>>
>> Also I would write the test as:
>>
>> if set(line).isdisjoint("abc"):
>>      print line
>>
>> Christian
>
> Thanks for the tip - I'm still learning Python and was unaware of the
> isdisjoint method.

If it's any consolation, I've been using Python for 10 years and
I was unaware of the isdisjoint method. :)

TJG

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar


Thread

Re: if statement multiple or Christian Heimes <lists@cheimes.de> - 2011-05-06 13:00 +0200
  Re: if statement multiple or scattered <tooscattered@gmail.com> - 2011-05-06 05:09 -0700
    Re: if statement multiple or Christian Heimes <lists@cheimes.de> - 2011-05-06 14:25 +0200
      Re: if statement multiple or scattered <tooscattered@gmail.com> - 2011-05-06 06:17 -0700
        Re: if statement multiple or Tim Golden <mail@timgolden.me.uk> - 2011-05-06 14:31 +0100

csiph-web