Deleting duplicate dictionaries in a list in python
<p>I have two lists of dictionaries</p>

<pre><code>list1 = [ {..}, {..}, ..]
list2 = [ {..}, {..}, ..]
</code></pre>

<p>I want to remove the dictionaries in list1 which are in list2. I had a similar problem where I had a list of lists instead of a dictionary and it is solved here</p>

<p><a href="http://stackoverflow.com/questions/1723494/python-function-slowing-down-for-no-apparent-reason">http://stackoverflow.com/questions/1723494/python-function-slowing-down-for-no-apparent-reason</a></p>

<p>If I use the same code which is, </p>

<pre><code>def removeDups(list1, list2):
    list2_set = set([tuple(x) for x in list2])
    diff = [x for x in list1 if tuple(x) not in list2_set]

    return diff
</code></pre>

<p>I do not get correct results since dictionaries like </p>

<pre><code>{key1:'a', key2:'b'} and 
{key2:'b', key1:'a'}
</code></pre>

<p>which are the same are actually considered as different. How can I change the code or what can I do to remove dictionaries from list1 that appear in list2?</p>
