I would like to write my own class Singleton that represents a set of size 1. It should
- subclass
frozensetso that all the usual set operations work seamlessly betweenSingleton,set,frozenset, and - add an assertion to
__init__offrozensetthat checks that the underlying set is constructed on an iterable of length 1.
What is a clean way to do this? Subclassing? Decorators? Thank you for your advice.