comparing values in two sets

bearophileHUGS at bearophileHUGS at
Mon May 15 01:29:09 CEST 2006

Note that you are comparing ordered sequences, like lists, tuples,
strings, etc, and not sets. Something like this can be a little
improvement of your code, it avoids building the zipped list, and scans
the iterable unpacking it on the fly:

from itertools import izip
def test_sets(original_set, trans_letters):
     for elem1, elem2 in izip(original_set, trans_letters):
         if elem1 == elem2:
             return False
     return True


More information about the Python-list mailing list