Type error Unhashable type:set
The individual items that you put into a set can't be mutable, because if they changed, the effective hash would change and thus the ability to check for inclusion would break down.
Instead, you need to put immutable objects into a set - e.g. frozenset
s.
If you change the return statement from your enum
method to...
return [frozenset(i) for i in L]
...then it should work.
This error is raised because a set can only contain immutable types. Or sets are mutable. However there is the frozenset
type :
In [4]: a, b = {1,2,3}, {2,3,4}In [5]: set([a,b])---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-5-6ca6d80d679c> in <module>()----> 1 set([a,b])TypeError: unhashable type: 'set'In [6]: a, b = frozenset({1,2,3}), frozenset({2,3,4})In [7]: set([a,b])Out[7]: {frozenset({1, 2, 3}), frozenset({2, 3, 4})}