intersection of three sets in python?
        Posted  
        
            by 
                Phil Brown
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Phil Brown
        
        
        
        Published on 2012-10-08T21:36:20Z
        Indexed on 
            2012/10/08
            21:36 UTC
        
        
        Read the original article
        Hit count: 354
        
Currently I am stuck trying to find the intersection of three sets. Now these sets are really lists that I am converting into sets, and then trying to find the intersection of.
Here's what I have so far:
for list1 in masterlist: list1=thingList1 for list2 in masterlist: list2=thingList2 for list3 in masterlist: list3=thingList3
d3=[set(thingList1), set(thingList2), set(thingList3)] setmatches c= set.intersection(*map(set,d3)) print setmatches
and I'm getting
set([]) Script terminated.
I know there's a much simpler and better way to do this, but I can't find one...
© Stack Overflow or respective owner