Quick actions

cmd+k|ctrl+k

Navigation

Languages

Sale (Dec. Usage) 2

Snippet info

Language

Python

Visibility

public

Author

chausage

Created

2025-01-22T07:12:27.391561Z

Updated

2025-01-22T07:26:40.336258Z

def dec(func):
    amount = 0
    def wrapper(sales):
        nonlocal amount
        amount +=sales #amount = amount + sales
        func(amount)
    return wrapper
    
@dec
def producton(sales):
    print("total amount is:", sales)
    
@dec
def shipping(cost):
    print("total expense:", cost) #cost will substitute sales in dec()
producton(10)
shipping(20)
producton(30)
shipping(100)
INFO