Skip to content

Instantly share code, notes, and snippets.

@JackInTaiwan
Last active November 10, 2018 13:09
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/8779504fbcbd0d8420e9996fab3c8641 to your computer and use it in GitHub Desktop.
Save JackInTaiwan/8779504fbcbd0d8420e9996fab3c8641 to your computer and use it in GitHub Desktop.
def print_func_name(func):
def wrap():
print("Now use function '{}'".format(func.__name__))
func()
return wrap
def dog_bark():
print("Bark !!!")
def cat_miaow():
print("Miaow ~~~")
if __name__ == "__main__":
print_func_name(dog_bark)()
# > Now use function 'dog_bark'
# > Bark !!!
print_func_name(cat_miaow)()
# > Now use function 'cat_miaow'
# > Miaow ~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment