search between 2 files

Andres Rosado-Sepulveda arosado at
Wed Feb 4 15:01:18 CET 2004

José wrote:
> I'm newby in Python, and I'm working on a script to manage files.
> I have two files, one with a list of domains, and the other with a new 
> list of domains. I'd like to know if I have a repeated domain in the 
> new's one. I tried opening with readline(), with readlines(), but truly 
> I have no idea to countinue.
> Have anybody any question?

I think it would be something like this (iow, untested):

domainsFile = file(filename, "rw")
domains = f1.readlines()
newDomainsFile = file(filename2, "r")
for domain in newDomainsFile:
....if not domain in domains:

Andres Rosado
Email: andresr at
ICQ: 66750646
AIM: pantear

"Oh boo! Boo hoo! Oh! ... don't stop now ... you motorheads're killin'
         -- A surprisingly alive Rattrap, "A Better Mousetrap"

More information about the Python-list mailing list