Skip to content

Instantly share code, notes, and snippets.

@agusrichard
Last active January 23, 2021 17:16
Show Gist options
  • Save agusrichard/3f21a33dcd291381ca8b7c53ef22c60d to your computer and use it in GitHub Desktop.
Save agusrichard/3f21a33dcd291381ca8b7c53ef22c60d to your computer and use it in GitHub Desktop.
import functools
def do_ten_times(func):
"""Repeats func ten times"""
@functools.wraps(func)
def wrapper():
for i in range(10):
func()
return wrapper
@do_ten_times
def say_hi():
print("Hiiiii....")
print(say_hi.__name__)
say_hi()
# Returns
# say_hi
# Hiiiii....
# Hiiiii....
# Hiiiii....
# Hiiiii....
# Hiiiii....
# Hiiiii....
# Hiiiii....
# Hiiiii....
# Hiiiii....
# Hiiiii....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment