from time import time def timer(any_function): def count_time(): start = time() any_function() stop = time() print("%.15f"%(stop-start),'seconds') return return count_time @timerdef hello(): print("Hello World") return @timerdef another_function(): for item in [1,2,3,4,5,6,7,8,9]: print("%d "%item,end='') print() return hello() another_function()
20 December 2017
Example of decorator in pyhon
Subscribe to:
Post Comments (Atom)
-
Problem Explanation Problem Category : Medium Algorithm: Binary Search, Mathematical Simulation For this problem, if you know how to f...
-
Problem Explanation Category: Easy Type: String Ad Hoc This is simple string ad hoc problem. You just need to find out a substring of...
-
Explanation category : Easy You just need to sum up all numbers. If you find any negative number just make it positive. Source code l...
No comments:
Post a Comment