title: intersection of three sets in python?
body: <p>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.</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>and I'm getting</p>
  
  <pre><code>set([]) 
  Script terminated.
  </code></pre>
  
  <p>I know there's a much simpler and better way to do this, but I can't find one...</p>
  
  <p><em>EDIT</em></p>
  
  <p>Okay, here's what I have now.</p>
  
  <pre><code>setList=()
  setList2=()
  setList3=()
  
  for list1 in masterlist:
      setList=list1
      for list2 in masterlist:
          setList2=list2
          for list3 in masterlist:
              setList3=list3
  
  
  
  setmatches=set(setList) &amp; set(setList2) &amp; set(setList3)
  print setmatches
  </code></pre>
  
  <p>Still doesn't give me what I'm looking for: which is the one match I ensured was in each list. It's giving me what looks like an addition of all the sets.</p>