You're trying to build a set
of set
s, recursively. This is not allowed because set
s are unhashable
and therefore cannot be placed in a set
. You can use a frozenset
because they are hashable.
try:
states = frozenset({nfa_eclosure(M, x+1) for x in xrange(len(M[s])) if M[s].get('')})
except IndexError:
states = frozenset([])
set
s are unordered, precisely because they are ordered internally by the hash of their members. This allows for fast lookup of set members.