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
This function will return the caller's function name.
def func_name(): import traceback return traceback.extract_stack(None, 2)[0][2]
It is like Albert Vonpupp's answer with a friendly wrapper.