Last active
December 9, 2020 00:14
-
-
Save illbebach/1d248a48f8b3e0bcdb40795c40c1009a to your computer and use it in GitHub Desktop.
get your python function name
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
import inspect | |
def get_func_name() -> str: | |
''' return a string of the caller's function name ''' | |
return inspect.currentframe().f_back.f_code.co_name | |
def func1(arg1, arg2): | |
print(get_func_name(), arg1, arg2) | |
func1(1,2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment