From 27bdd6d34abcc67bde6156b92fbed7b4694021be Mon Sep 17 00:00:00 2001 From: MexTest Date: Fri, 13 Jan 2023 10:31:00 +0000 Subject: [PATCH] - --- task1.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 task1.py 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