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


Groups > comp.lang.python > #99960

Re: filter a list of strings

Path csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Jussi Piitulainen <harvesting@is.invalid>
Newsgroups comp.lang.python
Subject Re: filter a list of strings
Date Thu, 03 Dec 2015 17:02:07 +0200
Organization A noiseless patient Spider
Lines 20
Message-ID <lf5oae7r2xc.fsf@ling.helsinki.fi> (permalink)
References <mailman.155.1449122975.14615.python-list@python.org> <lf51tb459f2.fsf@ling.helsinki.fi> <n3pis2$aa6$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info mx02.eternal-september.org; posting-host="305c68510616a2e7ac08bcd2ff1598bd"; logging-data="23116"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qtE9QdOJUKz4LxubK/gnlR9Kd+xk+vhA="
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:50qlv/3x7IrdRNBNnKRAIhw4d8A= sha1:UFMQJrJnljsm4H/zcl0/MzaNLiE=
Xref csiph.com comp.lang.python:99960

Show key headers only | View raw


Denis McMahon writes:

> On Thu, 03 Dec 2015 08:32:49 +0200, Jussi Piitulainen wrote:
>
>> def isbad(item):
>>     return ( 'Banana' in item or
>>              'Car' in item )
>>
>> def isgood(item)
>>     return not isbad(item)
>
> badthings = [ 'Banana', 'Car', ........]
>
> def isgood(item)
>     for thing in badthings:
>         if thing in item:
>             return False
>     return True

As long as all conditions are of that shape.

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


Thread

filter a list of strings <c.buhtz@posteo.jp> - 2015-12-03 02:15 +0100
  Re: filter a list of strings Jussi Piitulainen <harvesting@is.invalid> - 2015-12-03 08:32 +0200
    Re: filter a list of strings <c.buhtz@posteo.jp> - 2015-12-03 10:27 +0100
      Re: filter a list of strings Jussi Piitulainen <harvesting@is.invalid> - 2015-12-03 13:53 +0200
      Re: filter a list of strings Peter Pearson <pkpearson@nowhere.invalid> - 2015-12-05 19:42 +0000
    Re: filter a list of strings Chris Angelico <rosuav@gmail.com> - 2015-12-03 20:40 +1100
    Re: filter a list of strings Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-12-03 10:46 +0100
    Re: filter a list of strings Laura Creighton <lac@openend.se> - 2015-12-03 10:53 +0100
    Re: filter a list of strings jmp <jeanmichel@sequans.com> - 2015-12-03 11:03 +0100
    Re: filter a list of strings Peter Otten <__peter__@web.de> - 2015-12-03 11:13 +0100
    Re: filter a list of strings Denis McMahon <denismfmcmahon@gmail.com> - 2015-12-03 14:16 +0000
      Re: filter a list of strings Jussi Piitulainen <harvesting@is.invalid> - 2015-12-03 17:02 +0200
  Re: filter a list of strings Grobu <snailcoder@retrosite.invalid> - 2015-12-03 13:17 +0100

csiph-web