On 12/03/2012 10:46 AM, Spectral None wrote: > <snip> > Hi Dave > > Your solution seems to work: > > setA = set(FileA) > setB = set(FileB) > > for line in setB: > if line in setA: > matched_lines.writelines(line) > else: > non_matched_lines.writelines(line) > > There are no duplicates in the results as well. Thanks for helping out >
You didn't specify whether you wanted dups to be noticed. You had said that there were none in A, but B was unspecified. The other question is order. If you want original order, you'd have to omit the setB step, and iterate on FileB. And then eliminate dups as you go. Or if you want sorted order without dups, you could simply iterate on sorted(setB). -- DaveA _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor