Quick actions

cmd+k|ctrl+k

Navigation

Languages

Decorator function

Snippet info

Language

Python

Visibility

public

Author

chausage

Created

2025-01-22T06:53:37.999692Z

Updated

2025-01-22T06:53:37.999692Z

def dec(func):
    count = 0
    def wrapper():
        nonlocal count
        count +=1
        print("before external function is called")
        func()
        print("after external function is called:", count)
    return wrapper
    
@dec
def hello():
    print("hello")

hello()
hello()
INFO