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
my_function.func_name
There are also other fun properties of functions. Type dir(func_name) to list them. func_name.func_code.co_code is the compiled function, stored as a string.
dir(func_name)
func_name.func_code.co_code
import dis dis.dis(my_function)
will display the code in almost human readable format. :)