Categories
Python Answers

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

Spread the love

Sometimes, we want to get a function name as a string with Python.

In this article, we’ll look at how to get a function name as a string with Python.

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

To get a function name as a string with Python, we can use the __name__ property.

For instance, we write

my_function.__name__

to get the __name__property of my_function to return my_function‘s name as a string.

Conclusion

To get a function name as a string with Python, we can use the __name__ property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *