class ImmutableDict(dict):

    def __setitem__(self, key, value):
        raise Exception("Can't touch this")

def __hash__(self):
    return hash(tuple(sorted(self.items())))
a = ImmutableDict({'a': 1})
b = {a: 1}
print(b)
print(b[a])
a['a'] = 0
Immutable dictionary, only use as a key for another dictionary