Computer >> Computer tutorials >  >> Programming >> Python

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


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