title: Pythonic way to parse list of dictionaries for a specific attribute?
body: <p>I want to cross reference a dictionary and django queryset to determine which elements have unique <code>dictionary['name']</code> and <code>djangoModel.name</code> values, respectively.  The way I'm doing this now is to:  </p>
  
  <ul>
  <li>Create a list of the dictionary['name'] values</li>
  <li>Create a list of djangoModel.name values </li>
  <li>Generate the list of unique values by checking for inclusion in those lists</li>
  </ul>
  
  <p>This looks as follows:</p>
  
  <pre><code>alldbTests = dbp.test_set.exclude(end_date__isnull=False)   #django queryset
  
  vctestNames = [vctest['name'] for vctest in vcdict['tests']]   #from dictionary
  dbtestNames = [dbtest.name for dbtest in alldbTests]    #from django model
  
  # Compare tests in protocol in fortytwo's db with protocol from vc
  
  obsoleteTests = [dbtest for dbtest in alldbTests if dbtest.name not in vctestNames]
  newTests = [vctest for vctest in vcdict if vctest['name'] not in dbtestNames]
  </code></pre>
  
  <p>It feels unpythonic to have to generate the intermediate list of names (lines 2 and 3 above), just to be able to check for inclusion immediately after.  Am I missing anything?  I suppose I could put two list comprehensions in one line like this:</p>
  
  <pre><code>obsoleteTests = [dbtest for dbtest in alldbTests if dbtest.name not in [vctest['name'] for vctest in vcdict['tests']]]
  </code></pre>
  
  <p>But that seems harder to follow.</p>
  
  <p><strong>Edit</strong>:
  Think of the initial state like this:</p>
  
  <pre><code># vcdict is a list of django models where the following are all true
  alldBTests[0].name == 'test1'
  alldBTests[1].name == 'test2'
  alldBTests[2].name == 'test4'
  
  dict1 = {'name':'test1', 'status':'pass'}
  dict2 = {'name':'test2', 'status':'pass'}
  dict3 = {'name':'test5', 'status':'fail'}
  
  vcdict = [dict1, dict2, dict3]
  </code></pre>
  
  <p>I can't convert to sets and take the difference unless I strip things down to just the name string, but then I lose access to the rest of the model/dictionary, right?  Sets only would work here if I had the same type of object in both cases.</p>