Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4830
| Date | 2011-05-06 14:31 +0100 |
|---|---|
| From | Tim Golden <mail@timgolden.me.uk> |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1247.1304688706.9059.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Find similar
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