Created
March 7, 2016 16:39
-
-
Save wolendranh/57cf454ba72f91ca4918 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from functools import wraps | |
import time | |
from math import pi | |
def type_check(func): | |
@wraps(func) | |
def type_wrapper(*args, **kwargs): | |
result = func(*args, **kwargs) | |
print '{}: {}; type is {}'.format(func.__name__, result, str(type(result)).split(' ')[-1][1:-2]) | |
return result | |
return type_wrapper | |
def timer(func): | |
@wraps(func) | |
def timer_wrapper(*args, **kwargs): | |
t = time.time() | |
result = func(*args, **kwargs) | |
print u'виконання %s зайняло: %f' % (func.__name__, (time.time() - t)) | |
return result | |
return timer_wrapper | |
@type_check | |
@timer | |
def multiply(x, y, c): | |
return (x*y) - (c*pi)**2 | |
print multiply(2123123.5234343, 3234, 17) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment