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


Groups > comp.lang.python > #6806 > unrolled thread

Re: Python regexp exclude problem

Started byMRAB <python@mrabarnett.plus.com>
First post2011-06-01 18:12 +0100
Last post2011-06-01 18:12 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python regexp exclude problem MRAB <python@mrabarnett.plus.com> - 2011-06-01 18:12 +0100

#6806 — Re: Python regexp exclude problem

FromMRAB <python@mrabarnett.plus.com>
Date2011-06-01 18:12 +0100
SubjectRe: Python regexp exclude problem
Message-ID<mailman.2375.1306948343.9059.python-list@python.org>
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 ...)".

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web