Decorators - sjherrick/code-base GitHub Wiki

Decorators

Syntax

def decorator(func):
    def wrapper():
        # Do some stuff before func
        func()
        # Do some stuff after func

    return wrapper

@decorator
def function():
   # Function stuff

function()    # function = decorator(function)