In Python, the original dict list is as follows:
orig = [{'team': 'team1', 'other': 'blah', 'abbrev': 't1'},
{'team': 'team2', 'other': 'blah', 'abbrev': 't2'},
{'team': 'team3', 'other': 'blah', 'abbrev': 't3'},
{'team': 'team1', 'other': 'blah', 'abbrev': 't1'},
{'team': 'team3', 'other': 'blah', 'abbrev': 't3'}]
Need to get a new dict list of just team and abbrev but of distinct teams into a list like this:
new = [{'team': 'team1', 'abbrev': 't1'},
{'team': 'team2', 'abbrev': 't2'},
{'team': 'team3', 'abbrev': 't3'}]
dict keys are unique, which you can exploit:
Can’t help to suggest that a dict might be your data structure of choice to begin with.
Oh, I don’t know how
dict()reacts to the fact that there are several identical keys in the list. You may have to construct the dictionary less pythonesque in that case:implicitly overriding double entries