Skip to content

Instantly share code, notes, and snippets.

@ridwanray
Created May 3, 2024 17:30
Show Gist options
  • Select an option

  • Save ridwanray/d76e4cfee74d1d8cf9d4a0ea75e5dc6c to your computer and use it in GitHub Desktop.

Select an option

Save ridwanray/d76e4cfee74d1d8cf9d4a0ea75e5dc6c to your computer and use it in GitHub Desktop.
Decorator embded in a function
def my_decorator(argument):
def actual_decorator(func):
def wrapper(*args, **kwargs):
print(f"Decorator argument: {argument}")
result = func(*args, **kwargs)
return result
return wrapper
return actual_decorator
@my_decorator("example_argument")
def my_function():
print("Function called")
my_function()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment