Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # https://pastebin.com/MfJF9JdD
- import functools
- def polygon_square(func):
- @functools.wraps(func)
- def wrapper(*args, **kwargs):
- result = func(*args, **kwargs)
- # print(f"Pole pow.: ", end="")
- for ind, arg in enumerate(args, 97): # chr(97) => 'a'
- print(f"bok {chr(ind)} = {arg}" )
- print(f"{result[0]} - pole pow.: {result[1]} ")
- return result
- return wrapper
- @polygon_square
- def quadrat(side):
- return ("kwadrat", side ** 2)
- @polygon_square
- def rectangle(side_a, side_b):
- return ("prostokÄ…t", side_a * side_b)
- quadrat(4)
- rectangle(3, 2)
- def animal_presentation(func):
- @functools.wraps(func)
- def wrapper(*args, **kwargs):
- print("Ten zwierzak to: ")
- result = func(*args, *kwargs)
- return result
- return wrapper
- @animal_presentation
- def dog():
- print("piesek")
- print("hau, hau!!!")
- @animal_presentation
- def cat():
- print("kotek")
- print("mrau, mrau...")
- # dog()
- # cat()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement