OK Duh.. 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) 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.. Thanks rh0dium wrote: > Hi all, > > Ok I have a list > > hosts = [ "poundcake.fqdn.com", "scorpion.fqdn.com", "loghost", > "scorpian", "localhost", "lan", "lan.fpdn.com" ] > > Assumptions: > scorpian.fqdn.com == scorpian > lan == lan.fqdn.com > > I want pear this list down based on the following: > 1. ignore loghost, localhost, timehost, mailhost > 2. Use the first found name used reguardless if it is the fqdn or not > > So what you would get back out is this.. > > hosts = [ "poundcake.fqdn.com", "scorpion.fqdn.com", "lan" ] > > Now here is my code - and I have a problem with the splitting. I am > really looking for a cool ( but understandable ) way to simplify this.. > > e =[] > for host in hosts: > > sn = re.split( "\.", host) > > ig = 1 > ignore = [ "localhost", "loghost", "timehost", "mailhost" ] > for i in ignore: > if i == sn[0]: > ig = 0 > if ig: > print "%s not ignored" % sn[0] > found = 0 > for n in e: > sm = re.split( "\.", n) > print "checking %s to %s" % (sm[0], sn[0]) > if sm[0] == sn[0]: > print "match"; > found = 1 > if found == 0: > print "appending %s " % host > e.append(host) > > print e > > > Which kicks out.. > poundcake not ignored > appending poundcake.nsc.com > scorpion not ignored > checking poundcake to scorpion > appending scorpion.nsc.com > scorpian not ignored > checking poundcake to scorpian > checking scorpion to scorpian > appending scorpian > lan not ignored > checking poundcake to lan > checking scorpion to lan > checking scorpian to lan > appending lan > ['poundcake.fpdn.com', 'scorpion.fpdn.com', 'scorpian', 'lan'] > > Crap still wrong. -- http://mail.python.org/mailman/listinfo/python-list