"Paul McGuire" <[EMAIL PROTECTED]> writes: > A step further: use union to make a superset of t2-tN, then use & on > this superset. > > setlist = [t2,t3,t4,t5] > superset = reduce(set.union, map(set,setlist) ) > print bool(t1 & superset)
Well you do have to convert them to sets. Also I thought each intersection was wanted separately. Otherwise if we're getting this fancy, I guess I'd use (untested, uses new 2.5 "any" function): s1 = set(t1) print any((s1 & set(tn)) for tn in (t2,t3,t4,t5)) which avoids creating a potentially big intermediate set, and which short-circuits (exits early) as soon as a match is found. -- http://mail.python.org/mailman/listinfo/python-list