You can do this by creating a subclass of frozenset and overriding its __repr__ method: class MyFrozenSet(frozenset): def __repr__(self): return '([{}])'.format(', '.join(map(repr, self))) ... >>> lst = [['yes'], ['red', 'blue']] >>> [MyFrozenSet(x) for x in lst] [(['yes']), (['blue', 'red'])] ...

python,python-3.x,hash,frozenset

From the definition of hashable: Hashable objects which compare equal must have the same hash value. You have now implemented a new __eq__ method but not a new __hash__ for NewFrozenSet. Python now can't assume that the above property holds (i.e., that the behaviour of __eq__ and __hash__ matches) so...

You seem to have stumbled upon two frozensets with equal hash codes and different contents. This is not so strange as it may seem as the property of hash codes are that they are guaranteed to be equal for equal objects and probably different for non-equal objects. From the Python...