title: copy part of one dict to a new dict based on a list of keys
body: <p>Sample:</p>
  
  <pre><code>d = {
      "test": 1,
      "sample": 2,
      "example": 3,
      "product": 4,
      "software": 5,
      "demo": 6,
  }
  
  filter_keys = ["test","sample","example","demo"]
  </code></pre>
  
  <p>I want to create a new dict that contains only those items from the first dict whose keys appear in the list. In other words, I want:</p>
  
  <pre><code>d2 = {
      "test": 1,
      "sample": 2,
      "example": 3,
      "demo": 6,
  }
  </code></pre>
  
  <p>I could do it with a loop:</p>
  
  <pre><code>d2 = {}
  for k in d.keys():
      if (k in filter_keys): 
          d2[k] = d[k]
  </code></pre>
  
  <p>But this seems awfully "un-Pythonic". I'm also guessing that if you had a huge dict, say 5,000 items or so, the constant adding of new items to the new dict would be slow compared to a more direct way.</p>
  
  <p>Also, you'd want to be able to handle errors. If the list contains something that's not a key in the dict, it should just be ignored. Or maybe it gets added to the new dict but with a value of None.</p>
  
  <p>Is there a better way to accomplish this?</p>