python attribute decorator
To create a decorator in python is really easy. If you apply hello_world_decorator to say any method, it will execute the wrapper first.
def hello_world_decorator(func):
def wrapper(*args, **kwargs):
print("Hello, world")
return func(*args, **kwargs)
return wrapper
class Employee(BaseModel):
name: str
id: int
@hello_world_decorator
def hello(_self):
print("emplyoee")
So you will get the following output
Hello, world
employee
Comments