14 Sep
2021
14 Sep
'21
6:29 a.m.
As pointed out, you want metaclass for this. A warning, I've overwritten many of the dunders on classes for fun and I actually broke the ability to repr my class in certain situations by overriding __eq__ and/or __hash__ something deep in ipython/python with the repr. I forget the exact situation, I think I implemented __eq__ but not __hash__ and it broke the golden rule of x == y => x is y i,.e. hash(x) == hash(y) Great way to really learn the data model but you will be in for a bit of pain trying to debug these things.