Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import wraps
- def hash_deco(func):
- hash_dict={}
- @wraps(func)
- def wrappper(*args, **qwargs):
- res = func(*args, **qwargs)
- print(f"Heshing result {func.__name__}")
- key = hash(*args, **qwargs)
- hash_dict[key] = res
- print(hash_dict)
- return res
- return wrappper
- @hash_deco
- def fun(x):
- x = x + 1
- return x
- print(fun(5))
- print(fun(10))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement