Convert a list of sets to a set of sets (to find the unique elements)
Question: I want to find the unique elements in `A =[set([1,2]),set([1,2]), set([1])]`
in Python. I tried set(A); it didn't work. Is there any easy way to do it?


Answer: Convert your sets to [`frozenset()`
objects](http://docs.python.org/2/library/stdtypes.html#frozenset):

    
    
    set(frozenset(s) for s in A)
    

A `frozenset()` is an immutable set object, and more importantly, hashable.
Thus it can be stored in a `set()`.

Demo:

    
    
    >>> A = [set([1,2]),set([1,2]), set([1])]
    >>> set(frozenset(s) for s in A)
    set([frozenset([1, 2]), frozenset([1])])
    

