diff --git a/task1.py b/task1.py new file mode 100644 index 0000000..211f06b --- /dev/null +++ b/task1.py @@ -0,0 +1,20 @@ +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