-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecorator.py
More file actions
67 lines (58 loc) · 1.23 KB
/
Decorator.py
File metadata and controls
67 lines (58 loc) · 1.23 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# decorator
def decor_result(result_functon):
def distinction(marks):
for m in marks:
if m >= 75:
print('congrats !!, you have got distinaction')
else:
result_functon(marks)
return distinction
@decor_result
def result(marks):
for m in marks:
if m >= 33:
pass
else:
print('Fall')
break
else:
print('PASS')
result([50, 60, 15, 96, 66])
#result([50, 60, 75, 90, 66])
def result(marks):
for m in marks:
if m >= 33:
pass
else:
print('Fall')
break
else:
print('PASS')
result([50, 60, 70, 80, 44])
# fist 1 logic
def num():
print("we will use this function")
print("and will enhance this in decoration")
def decor(fun):
def inner():
print("If: befro enhancing function")
fun()
print("after enhancing function")
return inner
hi = decor(num)
hi()
# secend 2 logic
def decor(fun):
def inner():
a = fun() + 5
return a
return inner
def decor_1(sos):
def inner_1():
a = sos() + 5
return a
return inner_1
def num():
return 20
ai = decor(decor_1(num))
print(ai())