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


Groups > comp.lang.python > #6795

Re: Python regexp exclude problem

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.06; 'url:pypi': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'thorough': 0.14; 'router.': 0.16; 'header:In-Reply-To:1': 0.21; 'subject:problem': 0.22; 'trying': 0.23; 'problem?': 0.23; 'script': 0.27; 'module': 0.30; 'header:X-Complaints-To:1': 0.32; 'to:addr:python-list': 0.33; 'list.': 0.33; '...': 0.34; '[1]': 0.34; 'header:User-Agent:1': 0.35; 'like:': 0.35; 'url:python': 0.38; 'received:org': 0.38; 'hello,': 0.38; 'url:org': 0.38; 'subject:: ': 0.38; 'addresses': 0.39; 'christian': 0.39; 'header :Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'skip:2 10': 0.61; 'address': 0.62; 'our': 0.63; 'schrieb': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Christian Heimes <lists@cheimes.de>
Subject Re: Python regexp exclude problem
Date Wed, 01 Jun 2011 16:29:37 +0200
References <BANLkTimf0_cBy5g8ng6bik8QEgZJVFNS_A@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host smtp.semantics.de
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2.102ipre2 Thunderbird/3.1.10
In-Reply-To <BANLkTimf0_cBy5g8ng6bik8QEgZJVFNS_A@mail.gmail.com>
X-Enigmail-Version 1.1.2
OpenPGP id=AD16AB1B; url=http://cheimes.de/heimes.asc
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.2366.1306938594.9059.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 82.94.164.166
X-Trace 1306938594 news.xs4all.nl 49045 [::ffff:82.94.164.166]:48267
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6795

Show key headers only | View raw


Am 01.06.2011 16:20, schrieb Lutfi Oduncuoglu:
> 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 recommend the ipaddr module [1] for the job. It supports nice features
like:

  if IPAddress("144.122.23.42") in IPNetwork("144.122.0.0/16"):
      ...

Christian


[1] http://pypi.python.org/pypi/ipaddr

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


Thread

Re: Python regexp exclude problem Christian Heimes <lists@cheimes.de> - 2011-06-01 16:29 +0200

csiph-web