title: Is there a shorthand for querying a dictionary in python?
body: <p>Here's the type of query I want to execute, written in pseudocode:</p>
  <pre><code>select blob from blobs where blob['color'] == 'red' having maximum(blob['size'])
  </code></pre>
  <p>Obviously, I could write that like this in python:</p>
  <pre><code>redBlobs = [];
  
  for blob in blobs:
      if blob['color'] == 'red':
          redBlobs.append('blob')
  
  largestBlob = None
  
  for redBlob in redBlobs:
      if largestBlob == None or redBlob['size'] &gt; largestBlob['size']:
          largestBlob = redBlob
  
  return largestBlob
  </code></pre>
  <p>But I suspect there's a cleaner way of doing it. I'm new to python, so I'm still aproaching it very imperatively.</p>
  <h3>EDIT:</h3>
  <p>Here's a solution I came up with after looking at some other questions on SO:</p>
  <pre><code>max([blob for blob in blobs if blob['color'] == 'red'], key = lambda b: b['size'])
  </code></pre>
  <p>Presumably, there are better ways.</p>