Advertisement
palmux

PythonPillola #12.2

Jul 19th, 2024
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | Source Code | 0 0
  1. def repeat(num_times):
  2.     def decorator_repeat(func):
  3.         def wrapper(*args, **kwargs):
  4.             for _ in range(num_times):
  5.                 result = func(*args, **kwargs)
  6.             return result
  7.         return wrapper
  8.     return decorator_repeat
  9.  
  10. @repeat(num_times=3)
  11. def greet(name):
  12.     print(f"Ciao, {name}!")
  13.  
  14. greet("Dee")
Tags: python pillola
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement