Quick actions

cmd+k|ctrl+k

Navigation

Languages

Sales (decorator usage) 1

Snippet info

Language

Python

Visibility

public

Author

chausage

Created

2025-01-22T06:56:56.469297Z

Updated

2025-01-22T07:04:53.28994Z

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