This paste expires on 2023-08-08 22:56:13.498198. Repaste, or download this paste. . Pasted through v1-api.

def deco1(f):
    def _wrapper(*args, **kwargs):
        print("Hello from deco1()")
        return f(*args, **kwargs)
    return _wrapper
def deco2(f):
    def _wrapper(*args, **kwargs):
        print("Hello from deco2()")
        return f(*args, **kwargs)
    return _wrapper
@deco2
@deco1
def func(x):
    print(f"This is func({x=})")
def other_func(x):
    print(f"This is other_func({x=})")
# equivalent to above
other_func = deco2(deco1(other_func))
func(42)
print("---")
other_func(42)
Filename: thuna.py. Size: 502b. View raw, , hex, or download this file.
18:56 [snoopjedi@denton ~/scratch]
$ python3 thuna.py
Hello from deco2()
Hello from deco1()
This is func(x=42)
---
Hello from deco2()
Hello from deco1()
This is other_func(x=42)
Filename: out.txt. Size: 179b. View raw, , hex, or download this file.