title: Python filtering list of objects by distinct attribute
body: <p>I have a list of objects with multiple attributes. I want to filter the list based on one attribute of the object (country_code), i.e.</p>
  
  <p>Current list</p>
  
  <pre><code>elems = [{'region_code': 'EUD', 'country_code': 'ROM', 'country_desc': 'Romania', 'event_number': '6880'}, 
  {'region_code': 'EUD', 'country_code': 'ROM', 'country_desc':'Romania', 'event_number': '3200'}, 
  {'region_code': 'EUD', 'country_code': 'ROM', 'country_desc': 'Romania', 'event_number': '4000'}, 
  {'region_code': 'EUD', 'country_code': 'SVN', 'country_desc': 'Slovenia', 'event_number': '6880'}, 
  {'region_code': 'EUD', 'country_code': 'NLD', 'country_desc':'Netherlands', 'event_number': '6880'}, 
  {'region_code': 'EUD', 'country_code': 'BEL', 'country_desc':'Belgium', 'event_number': '6880'}]
  </code></pre>
  
  <p>Desired list</p>
  
  <pre><code>elems = [{'region_code': 'EUD', 'country_code': 'ROM', 'country_desc': 'Romania', 'event_number': '6880'}, 
  {'region_code': 'EUD', 'country_code': 'SVN', 'country_desc': 'Slovenia', 'event_number': '6880'}, 
  {'region_code': 'EUD', 'country_code': 'NLD', 'country_desc': 'Netherlands', 'event_number': '6880'}, 
  {'region_code': 'EUD', 'country_code': 'BEL', 'country_desc': 'Belgium', 'event_number': '6880'}]
  </code></pre>
  
  <p>I can achieve this by creating a dictionary and a for-loop, but I feel like there's an easier way in python using the filter() or reduce() functions, I just can't figure out how.</p>
  
  <p><strong>Can anyone simplify the below code using in-built python functions? Performance is a big factor because the real data will be substantial.</strong></p>
  
  <p>Working code:</p>
  
  <pre><code>unique = {}
  for elem in elems:
    if elem['country_code'] not in unique.keys():
       unique[elem['country_code']] = elem
  
  print(unique.values())
  </code></pre>
  
  <p>Worth noting I have also tried the code below, but it performs worse than the current working code:</p>
  
  <pre><code>unique = []
  for elem in elems:
      if not any(u['country_code'] == elem['country_code'] for u in unique):
          unique.append(elem)
  </code></pre>