Skip to content

Instantly share code, notes, and snippets.

@techman83
Created April 7, 2021 07:50
Show Gist options
  • Save techman83/8aab2ccdc853acf43ecfcc421364150f to your computer and use it in GitHub Desktop.
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.
"""
➜ ~ 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