Python/Decorator

From Fundamental Ramen
< Python
Revision as of 04:01, 13 June 2019 by Tacoball (talk | contribs)
Jump to navigation Jump to search
TODO Code
def pre_hook(func):
    def wrapper(*args):
        a = args[0] + 1
        b = args[1] + 1
        return func(a, b)
    return wrapper
def post_hook(func):
    def wrapper(*args):
        print(func(*args))
    return wrapper
def duo_hook(func):
    def wrapper(*args):
        a = args[0] + 1
        b = args[1] + 1
        sum = func(a, b)
        print(sum)
        return sum
    return wrapper