-
-
Save esenthil2018/be7e51da9da48d525ad18114d2a6ab9e to your computer and use it in GitHub Desktop.
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
| # This the first decorator | |
| def decon_first(fn): | |
| # The new function the decorator returns | |
| def wrapper(): | |
| # Insertion of some code before and after | |
| print('This is the first decorator') | |
| return fn() | |
| return wrapper | |
| # This the second decorator | |
| def decon_second(fn): | |
| # The new function the decorator returns | |
| def wrapper(): | |
| # Insertion of some code before and after | |
| print('This is the second decorator') | |
| return fn() | |
| return wrapper | |
| @decon_first | |
| @decon_second | |
| def orig_nested(): | |
| return 'Nested Decorators' | |
| orig_nested() | |
| @decon_first | |
| @decon_second | |
| def orig_nested(): | |
| return 'Multi Nested Decorator' | |
| orig_nested() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment