Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6795
| From | Christian Heimes <lists@cheimes.de> |
|---|---|
| Subject | Re: Python regexp exclude problem |
| Date | 2011-06-01 16:29 +0200 |
| References | <BANLkTimf0_cBy5g8ng6bik8QEgZJVFNS_A@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2366.1306938594.9059.python-list@python.org> (permalink) |
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
Re: Python regexp exclude problem Christian Heimes <lists@cheimes.de> - 2011-06-01 16:29 +0200
csiph-web