-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdecorator_python.py
More file actions
45 lines (28 loc) · 799 Bytes
/
decorator_python.py
File metadata and controls
45 lines (28 loc) · 799 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class decorator_class:
def __init__(self,function):
self.function = function
def __call__(self, *args, **kwargs):
# print('wrapper before the main method {}'. format(self.function.__name__))
print('wrapper before the main method {}'.format(self.function))
return self.function()
# print(decorator_class('hello')())
#
@decorator_class
def add():
print('this is addition ')
# f = decorator_class(add)
# f()
add()
'''
def outer_functions(main_fun):
def inner_function():
print('wrapper run before main function name {}'.format(main_fun.__name__))
return main_fun()
return inner_function
@outer_functions
def display():
print('this is display in main function ')
# f = outer_functions(display)
# f()
display()
'''