Quick actions

cmd+k|ctrl+k

Navigation

Languages

declorator

Snippet info

Language

Python

Visibility

public

Author

chanronny48

Created

2025-04-17T06:25:27.553562Z

Updated

2025-04-17T06:37:04.886646Z

def counter(fn):
    count = 0
    def inner(*args, **kwargs):
        nonlocal count
        count +=1
        print('Function {0} was called {1} times'.format(fn.__name__, count))
        return fn(*args,**kwargs)
    return inner
@counter    
def add(a, b=0):
    return a+b
@counter
def mult(a,b):
    return a*b
#add = counter(add)
#result = add(1,2)
add(2,3)
INFO