Skip to content

Instantly share code, notes, and snippets.

@fwojciec
Created December 5, 2017 20:03
Show Gist options
  • Save fwojciec/336e698bb5c5887c6e9387ef8ed3c848 to your computer and use it in GitHub Desktop.
Save fwojciec/336e698bb5c5887c6e9387ef8ed3c848 to your computer and use it in GitHub Desktop.
Python Simple Decorator Template
import functools
def my_decorator(func):
@functools.wraps(func)
def function_that_runs_func():
print('Before the decorated function!')
func()
print('After the decorated function!')
return function_that_runs_func
@my_decorator
def my_function():
print('I\'m the function')
my_function()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment