Oop | Python 3 Deep Dive Part 4

. If a class defines how an object behaves, a metaclass defines how a behaves. By inheriting from

class ValidatedNumber: def __set_name__(self, owner, name): self.name = name def __set__(self, instance, value): if value < 0: raise ValueError(f"self.name must be positive") instance.__dict__[self.name] = value class Circuit: resistance = ValidatedNumber() Use code with caution. 4. Multiple Inheritance and MRO python 3 deep dive part 4 oop