def implicit_int(cls): def wrapper(self, item): if hasattr(object, item): return object.__getattr__(self, attr) else: return 0 cls.__getattr__ = wrapper return cls '''Тесты''' @implicit_int class A: x = -1 a = A() print(a) print(a.x) print(a.e) print(a.e + 589) # Вывод: 589