title: Python list comprehension for dictionaries in dictionaries?
body: <p>I just learned about list comprehension, which is a great fast way to get data in a single line of code. But something's bugging me.</p>
  
  <p>In my test I have this kind of dictionaries inside the list:</p>
  
  <pre><code>[{'y': 72, 'x': 94, 'fname': 'test1420'}, {'y': 72, 'x': 94, 'fname': 'test277'}]
  </code></pre>
  
  <p>The list comprehension <code>s = [ r for r in list if r['x'] &gt; 92 and r['x'] &lt; 95 and r['y'] &gt; 70 and r['y'] &lt; 75 ]</code> works perfectly on that (it is, in fact, the result of this line)</p>
  
  <p>Anyway, I then realised I'm not really using a list in my other project, I'm using a dictionary. Like so:</p>
  
  <pre><code>{'test1420': {'y': '060', 'x': '070', 'fname': 'test1420'}}
  </code></pre>
  
  <p>That way I can simply edit my dictionary with <code>var['test1420'] = ...</code></p>
  
  <p>But list comprehensions don't work on that!
  And I can't edit lists this way because you can't assign an index like that.</p>
  
  <p>Is there another way?</p>