Python - create dictionary from list of dictionaries
<p>I have a list of dictionaries in Python</p>

<pre><code>[
{'id':'1', 'name': 'test 1', 'slug': 'test1'},
{'id':'2', 'name': 'test 2', 'slug': 'test2'},
{'id':'3', 'name': 'test 3', 'slug': 'test3'},
{'id':'4', 'name': 'test 4', 'slug': 'test4'},
{'id':'5', 'name': 'test 5', 'slug': 'test4'}
]
</code></pre>

<p>I want to turn this list into a dictionary of dictionaries with the key being <code>slug</code>. If the slug is duplicated as in the example above it should just ignore it.  This can either be by copying over the other entry or not bothing to reset it, I'm not bothered as they <em>should</em> be the same.</p>

<pre><code>{
'test1': {'id':'1', 'name': 'test 1', 'slug': 'test1'},
'test2': {'id':'2', 'name': 'test 2', 'slug': 'test2'},
'test3': {'id':'3', 'name': 'test 3', 'slug': 'test3'},
'test4': {'id':'4', 'name': 'test 4', 'slug': 'test4'}
}
</code></pre>

<p>What is the best way to achieve this?</p>
