Skip to content

Instantly share code, notes, and snippets.

@lotusirous
Created January 25, 2019 08:20
Show Gist options
  • Select an option

  • Save lotusirous/3f2d2772da6500804303e3b67383a114 to your computer and use it in GitHub Desktop.

Select an option

Save lotusirous/3f2d2772da6500804303e3b67383a114 to your computer and use it in GitHub Desktop.
A sample wrapper with arguments
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