Created
April 7, 2021 07:50
-
-
Save techman83/8aab2ccdc853acf43ecfcc421364150f to your computer and use it in GitHub Desktop.
Sometimes you think you know a language, sometimes you question your entire existence.
This file contains 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
""" | |
➜ ~ python3 --version | |
Python 3.8.5 | |
➜ ~ python3 decorator_demo.py | |
--------------------- | |
Decorator Start... | |
No Space | |
Decorator End..... | |
--------------------- | |
Decorator Start... | |
One Space | |
Decorator End..... | |
--------------------- | |
Decorator Start... | |
Two Space | |
Decorator End..... | |
--------------------- | |
Decorator Start... | |
Ten Space | |
Decorator End..... | |
--------------------- | |
""" | |
def dec_demo(func): | |
def wrapper(): | |
print("Decorator Start...") | |
func() | |
print("Decorator End.....") | |
return wrapper | |
@dec_demo | |
def no_space(): | |
print("No Space") | |
@ dec_demo | |
def one_space(): | |
print("One Space") | |
@ dec_demo | |
def two_space(): | |
print("Two Space") | |
@ dec_demo | |
def ten_space(): | |
print("Ten Space") | |
print("---------------------") | |
no_space() | |
print("---------------------") | |
one_space() | |
print("---------------------") | |
two_space() | |
print("---------------------") | |
ten_space() | |
print("---------------------") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment