Skip to content

Instantly share code, notes, and snippets.

@JackInTaiwan
Last active December 14, 2021 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackInTaiwan/3fda507a8803d4d30a9a0f13df834f9c to your computer and use it in GitHub Desktop.
Save JackInTaiwan/3fda507a8803d4d30a9a0f13df834f9c to your computer and use it in GitHub Desktop.
import time
def print_func_name(time):
def decorator(func):
def wrap():
print("Now use function '{}'".format(func.__name__))
print("Now Unix time is {}.".format(int(time)))
func()
return wrap
return decorator
@print_func_name(time=(time.time()))
def dog_bark():
print("Bark !!!")
if __name__ == "__main__":
dog_bark()
# > Now use function 'dog_bark'
# > Now Unix time is 1639491313.
# > Bark !!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment