I am looking for a way to call magic methods on class instances. In my case, I want to call hash on class based on properties. I found solution with metaclass, but I cannot access class properties from metaclass's method.
class X(type):
@classmethod
def __hash__(cls):
return hash(cls.x)
class Y(metaclass=X):
x = (1, 2, 3)
assert hash(Y) == hash((1, 2, 3))
I found just this thread: Defining magic methods on classes