Decorators – Python

Decorators – One function takes argument as an another one function,

def test_dec(func):
    def test1(ip):
        ts = sum(ip)
        for x in range(len(ip)):
            yield ts-ip[x]
    return test1

@test_dec
def test2(ip):
    return ip
a = list(test2([1,2,3,4,5]))
print (a)
print (min(a)) #10
print (a)
print (max(a)) #14

Leave a comment