Created
February 22, 2020 13:05
-
-
Save rainbowbird/73ba7ee2af1867944bad0fe7da5baef8 to your computer and use it in GitHub Desktop.
Python decorators - Application of closures
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 decorator(func): | |
@functools.wraps(func) | |
def new_func(*args, **kwargs): | |
print('decorator was here') | |
return func(*args, **kwargs) | |
return new_func | |
@decorator | |
def add(a, b): | |
return a + b | |
print(add(2, 3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment