supermaster-dev
MexTest 2 years ago
parent 2c865b78b1
commit 27bdd6d34a
  1. 20
      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
Loading…
Cancel
Save