-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecorator.py
More file actions
23 lines (19 loc) · 725 Bytes
/
Copy pathdecorator.py
File metadata and controls
23 lines (19 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#Decorators are a very powerful and useful tool in Python since it allows programmers to modify the behaviour of a function or class
# greet will take a function and it will run good moring befoer calling the function adn thanks a lot after calling the function
# it will take a function as an arguement and it will return it after modifying it
def greet(fx):
def mfx(*args,**kwargs): # args and kwargs means that if it takes arguements then take them
print("good morning")
fx(*args,**kwargs)
print("thanks a lot")
return mfx
@greet
def add(a,b):
print(a+b)
@greet
def helo():
print("hi bro")
add(1,2)
helo()
#greet(hello)() this will work same as @greet
# greet(add)(2,3)