Skip to content

Instantly share code, notes, and snippets.

@elena-roff
Created August 28, 2018 09:03
Show Gist options
  • Save elena-roff/10eb6237c654d5520658b0428cf143de to your computer and use it in GitHub Desktop.
Save elena-roff/10eb6237c654d5520658b0428cf143de to your computer and use it in GitHub Desktop.
Decorator template
# source: https://realpython.com/primer-on-python-decorators/
# This formula is a good boilerplate template for building more complex decorators.
import functools
def decorator(func):
@functools.wraps(func)
def wrapper_decorator(*args, **kwargs):
# Do something before
value = func(*args, **kwargs)
# Do something after
return value
return wrapper_decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment