Using __setattr__ and __getattr__ for delegation with __slots__ without triggering infinite recursion
Using __setattr__ and __getattr__ for delegation with __slots__ without triggering infinite recursion Question: class A: __slots__ = ("a",) def __init__(self) -> None: self.a = 1 class B1: __slots__ = ("b",) def __init__(self, b) -> None: self.b = b def __getattr__(self, k): return getattr(self.b, k) def __setattr__(self, k, v): setattr(self.b, k, v) class B2: __slots__ = …