title: Python: Subsetting a list according to the attribute
body: <p>I have a list of instances of MC and I want to subset all the instances which attribute equals 2. Can you help me creating the function "superfunction" that does either subset according to a value to accept or to reject.</p>
  
  <pre><code>class MC(object):
       def __init__(self,smth):
           self.smth=smth
  
  l = [MC(2),MC(4),MC(1),MC(2),MC(2),MC(-3),MC(0)]
  
  def superfunction (a_list,attr,value_to_accept=None, value_to_reject=None):
       return a_subset
  </code></pre>
  
  <p>How would it work for a dictionnary ?</p>
  
  <p>Thanks a lot !</p>