применяется к методу, уже украшенному @property? (Я использую Python 3.10.)
Код: Выделить всё
# Define a decorator
def my_decorator(func):
def wrapper(*args, **kwargs):
print("Decorator applied")
return func(*args, **kwargs)
return wrapper
# Apply the decorator over the method
class MyClass:
@my_decorator
@property
def x(self):
return 42
# Test the decorated method
obj = MyClass()
print(obj.x) # should output "Decorator applied" followed by "42"
Код: Выделить всё