title: How Can I Get a Subset of an Object's Properties as a Python Dictionary?
body: <p><strong>Short Version:</strong></p>
  
  <p>In Python is there a way to (cleanly/elegantly) say "Give me these 5 (or however many) properties of an object, and nothing else, as a dictionary"?</p>
  
  <p><strong>Longer Version:</strong></p>
  
  <p>Using the Javascript Underscore library, I can reduce an bunch of objects/dictionaries (in JS they're the same thing) to a bunch of subsets of their properties like so:</p>
  
  <pre><code>var subsets = _(someObjects).map(function(someObject) {
      _(someObject).pick(['a', 'd']);
  });
  </code></pre>
  
  <p>If I want to do the same thing with a Python object (not a dictionary) however it seems like the best I can do is use a list comprehension and manually set each property:</p>
  
  <pre><code>subsets = [{"a": x.a, "d": x.d} for x in someObjects]
  </code></pre>
  
  <p>That doesn't look so bad when there's only two properties, and they're both one letter, but it gets uglier fast if I start having more/longer properties (plus I feel wrong whenever I write a multi-line list comprehension).  I could turn the whole thing in to a function that uses a for loop, but before I do that, is there any cool built-in Python utility thing that I can use to do this as cleanly (or even more cleanly) than the JS version?</p>