Created
January 25, 2019 08:20
-
-
Save lotusirous/3f2d2772da6500804303e3b67383a114 to your computer and use it in GitHub Desktop.
A sample wrapper with arguments
This file contains hidden or 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
| from functools import wraps | |
| def role_required(a: list): | |
| def with_roles(f): | |
| @wraps(f) | |
| def wrapper(*args, **kwds): | |
| print('Calling decorated function', a) | |
| return f(*args, **kwds) | |
| return wrapper | |
| return with_roles | |
| @role_required(["admin","guest"]) | |
| def hello(): | |
| print("from hello") | |
| hello() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment