Skip to content

Instantly share code, notes, and snippets.

@CEZERT
Created March 14, 2022 23:17
Show Gist options
  • Save CEZERT/01a22574ed1f4ee70aa62043f2bdf42d to your computer and use it in GitHub Desktop.
Save CEZERT/01a22574ed1f4ee70aa62043f2bdf42d to your computer and use it in GitHub Desktop.
import functools
import time
def slow_down(func):
"""Sleep 1 second before calling the function"""
@functools.wraps(func)
def wrapper_slow_down(*args, **kwargs):
time.sleep(1)
return func(*args, **kwargs)
return wrapper_slow_down
@slow_down
def countdown(from_number):
if from_number < 1:
print("Liftoff!")
else:
print(from_number)
countdown(from_number - 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment