Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.06; 'from:addr:python': 0.09; 'thorough': 0.14; 'wrote:': 0.14; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'reply- to:addr:python-list': 0.16; 'router.': 0.16; 'header:In-Reply- To:1': 0.21; 'subject:problem': 0.22; 'trying': 0.23; '"not': 0.23; 'problem?': 0.23; 'received:84': 0.25; 'string': 0.26; 'script': 0.27; 'problem': 0.28; 'to:addr:python-list': 0.33; "isn't": 0.33; 'list.': 0.33; 'header:User-Agent:1': 0.35; 'skip:" 10': 0.35; 'reply-to:addr:python.org': 0.35; 'think': 0.38; 'hello,': 0.38; 'subject:: ': 0.38; 'addresses': 0.39; 'either': 0.39; 'to:addr:python.org': 0.39; 'skip:2 10': 0.61; 'address': 0.62; 'our': 0.63; 'header:Reply-To:1': 0.72; 'reply-to:no real name:2**0': 0.72 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApYGANlx5k3Unw4S/2dsb2JhbABTmBOOE3fHRYYgBJUYimk Date: Wed, 01 Jun 2011 18:12:23 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python regexp exclude problem References: In-Reply-To: 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 Reply-To: python-list@python.org 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: 20 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306948343 news.xs4all.nl 49044 [::ffff:82.94.164.166]:48689 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6806 On 01/06/2011 15:20, Lutfi Oduncuoglu wrote: > Hello, > > I am trying to write a script for adding ip address to a list. Those ip > addresses coming thorough from our edge router. > I have a line in may script like > > if any(s not in z2 for s > in('144.122.','188.38','193.140.99.2','213.161.144.166','92.45.88.242')): > os.system(" echo " +z2+ " >> kapat_py_log") > > However ip addresses like 213.161.144.166 are added to the list. What > can I do about this problem? > I think the problem is that you have "any(s not in ...)". If you have the IP address "213.161.144.166", the string "144.122." isn't in it, so the "any" returns True. Try either "all(s not in z2 ...)" or "not any(s in z2 ...)".