Last active
November 10, 2018 13:09
-
-
Save JackInTaiwan/8779504fbcbd0d8420e9996fab3c8641 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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