- Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathPythonDecorators.py
More file actions
Latest commit
25 lines (14 loc) · 721 Bytes
/
Copy pathPythonDecorators.py
File metadata and controls
25 lines (14 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#Decorators
#Decorators can be thought of as functions which modify the functionality of another function. They help to make your code shorter and more "Pythonic".
#To properly explain decorators we will slowly build up from functions. Make sure to run every cell in this Notebook for this lecture to look the same on your own computer.
#Creating a Decorator
defnew_decorator(func):
defwrap_func():
print("Code would be here, before executing the func")
func()
print("Code here will execute after the func()")
returnwrap_func
deffunc_needs_decorator():
print("This function is in need of a Decorator")
#func_needs_decorator()
ThisfunctionisinneedofaDecorator