Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import random, randint, choice
- def our_decorator(func):
- def function_wrapper(*args, **kwargs):
- print("Before calling " + func.__name__)
- res = func(*args, **kwargs)
- print(res)
- print("After calling " + func.__name__)
- return function_wrapper
- for f in [random, randint, choice]:
- f = our_decorator(f)
- random()
- randint(3, 8)
- choice([4, 5, 6])
- Before calling random
- <random_value>
- After calling random
- Before calling randint
- <random_integer>
- After calling randint
- Before calling choice
- <random_choice>
- After calling choice
- <random_choice among 4,5 6>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement