How to get a function name as a string in Python?

PythonServer Side ProgrammingProgramming

Every function has a property called __name__ attached to it. We can access this property and get the name of a function. For example:

def some_func():
    return 0
print some_func.__name__

This will give us the output:

some_func
raja
Published on 13-Dec-2017 10:34:57
Advertisements