title: Intersection of two lists of dict - Python
body: <p>I have two lists of dict</p>
  
  <pre><code>listA = [{'id': 'abc', 'key1': '542696d8485b'}]
  listB = [{'id': 'abc', 'key1': '542696d8485b'}, {'id': 'def', 'key1': '27348628grn'}]
  </code></pre>
  
  <p>I want to extract <code>listC = [{'id': 'abc', 'key1': '542696d8485b'}]</code></p>
  
  <p>i.e I want to find intersection based on 'id' field( based on any one field, assuming common items in list are exactly same ). Suggest me some efficient pythonic way...</p>
  
  <p>How about something like</p>
  
  <pre><code>listA_set = set(item['id'] for item in listA)
  listB_set = set(item['id'] for item in listB)
  listC_set = listA_set &amp; listB_set
  listC = {item:listA[item] for item in listC_set}
  </code></pre>