In Python, how do I get a function name as a string, without calling the function?
def my_function(): pass print get_function_name_as_string(my_function
Try
import sys fn_name = sys._getframe().f_code.co_name
further reference https://www.oreilly.com/library/view/python-cookbook/0596001673/ch14s08.html