re.search experts needed on fqdn stripping..

Mike Meyer mwm at mired.org
Wed Sep 21 04:07:31 CEST 2005


"rh0dium" <sklass at pointcircle.com> writes:
> After thinking about it for a bit longer i simplified it but still have
> the same problem..
>
> e =[]
> hosts = [ "poundcake.fpdn.com", "scorpion.fpdn.com", "loghost",
> "scorpian", "localhost", "lan" ]
>
> ignore = [ "localhost", "loghost", "timehost", "mailhost" ]
>
> for host in hosts:
>     sn = re.split( "\.", host)

This should be host.split(".").

>     if not sn[0] in ignore:
>         e.append(host)
>         ignore.append(sn[0])
> print e
>
> But this STILL gives me some problems..
> ['poundcake.nsc.com', 'scorpion.fqdn.com', 'scorpian', 'lan']
>
> Nope - OK I am an idiot - try spelling idiot..

Can I take it that you saw that "scorpion" is not the same as
"scorpian"?

BTW, if you're using 2.4 and don't care about portability, I'd make
ignore a set instead of a list.

       <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list