Python: Unique items of list in the order that it appears
<p>In Python, we can get the unique items of the list using <code>set(list)</code>. However doing this breaks the order in which the values appear in the original list. Is there an elegant way to get the unique items in the order in which it appears in the list.</p>

<p>This is an elegant way:</p>

<pre><code>from collections import OrderedDict
list(OrderedDict.fromkeys(list))
</code></pre>

<p>It works if the list items are all hashable (you will know that all the list items are hashable if converting it to a set did not trigger an exception).  </p>

<p>If any items are not hashable, there's an alternative which is more robust at the price of poorer performance: I refer you to the <a href="http://stackoverflow.com/a/39755540/674039">answer</a> from Patrick Haugh.</p>

python list order set unique