Created
December 5, 2017 20:03
-
-
Save fwojciec/336e698bb5c5887c6e9387ef8ed3c848 to your computer and use it in GitHub Desktop.
Python Simple Decorator Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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