On 11/18/06 4:34 PM, "has" <[log in to unmask]> wrote: > Paul Berkowitz wrote: > >> That gets me the 'difference' items. I'd also like to get the line >> numbers >> of those items in the l2 text. > > See <http://docs.python.org/lib/module-sets.html>. > > from sets import Set > > list1 = [1,2,3,4,5,6] > list2 = [2,4,7] > > set1 = Set(list1) > set2 = Set(list2) > > unique_to_list1= list(set1 - set2) > print unique_to_list1 > > common_to_both = list(set1 & set2) > print common_to_both > > unique_to_list1_indexes = [list1.index(val) + 1 for val in > unique_to_list1] > print unique_to_list1_indexes > > common_to_both_indexes_for_list2= [list2.index(val) + 1 for val in > common_to_both] > print common_to_both_indexes_for_list2 > > > Bear in mind that if a source list contains multiple identical > values, only the first one will be considered. Also, remember that > case is considered when comparing text, so if you need to do case- > insensitive comparisons you'll need to normalise all the text > beforehand. Thanks, has. This is very helpful. And in this particular case I am searching through unique items, ASCII only (a list of GUIDs, in fact), so no extra manipulations are needed. -- Paul Berkowitz