From Python version 2.6 on you can use multiple arguments to set.intersection(), like
Copyu = set.intersection(s1, s2, s3)
If the sets are in a list, this translates to:
Copyu = set.intersection(*setlist)
where *a_list is list expansion
Note that set.intersection is not a static method, but this uses the functional notation to apply intersection of the first set with the rest of the list. So if the argument list is empty this will fail.
From Python version 2.6 on you can use multiple arguments to set.intersection(), like
Copyu = set.intersection(s1, s2, s3)
If the sets are in a list, this translates to:
Copyu = set.intersection(*setlist)
where *a_list is list expansion
Note that set.intersection is not a static method, but this uses the functional notation to apply intersection of the first set with the rest of the list. So if the argument list is empty this will fail.
As of 2.6, set.intersection takes arbitrarily many iterables.
Copy>>> s1 = set([1, 2, 3])
>>> s2 = set([2, 3, 4])
>>> s3 = set([2, 4, 6])
>>> s1 & s2 & s3
set([2])
>>> s1.intersection(s2, s3)
set([2])
>>> sets = [s1, s2, s3]
>>> set.intersection(*sets)
set([2])
Videos
I think you are simply looking for:
set(thingList1) & set(thingList2) & set(thingList3)
The ampersand is intersection in Python (and some other languages as well).
set1 & set2 & set3
should work ... at least I think
>>> set((1,2,3)) & set((2,3,4)) & set((3,4,5))
set([3])
Is there a difference between those? (in simple terms please,VERY new to Python)