Created
May 3, 2024 17:30
-
-
Save ridwanray/d76e4cfee74d1d8cf9d4a0ea75e5dc6c to your computer and use it in GitHub Desktop.
Decorator embded in a function
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
| 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