-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculate_functions.py
More file actions
73 lines (31 loc) · 862 Bytes
/
calculate_functions.py
File metadata and controls
73 lines (31 loc) · 862 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import time
import math
def calculate_time(func):
def inner_wrapper(*args, **kwargs):
begin = time.time()
#run the function
func(*args,**kwargs)
end = time.time()
print ( "total time taken by the funtion {} is {} sec".format(func.__name__, end - begin))
return inner_wrapper
@calculate_time
def factorial(num):
#time.sleep(2)
print (math.factorial(num))
# a new decorator funtion
def func_dec(func):
def inner_wrapper(*args,**kwargs):
print("this is the begining of the funtion")
value = func(*args, **kwargs)
print ("this is the end of the funtion")
return value
return inner_wrapper
@func_dec
@calculate_time
def sum1(a, b):
print ("Now we are in the sum Fucntion")
c = a + b
print ("we did the calculation and here is the end of this Fucntion", c )
#return c
soo= sum1(8,9)
#print (soo)