Categories
Python Answers

How to get list of parameter names inside Python function?

Spread the love

Sometimes, we want to get list of parameter names inside Python function.

In this article, we’ll look at how to get list of parameter names inside Python function.

How to get list of parameter names inside Python function?

To get list of parameter names inside Python function, we can use the func.__code__.co_varnames property on the function func.

For instance, we write

vars = func.__code__.co_varnames

to get a tuple of parameter names as strings of the function func.

Conclusion

To get list of parameter names inside Python function, we can use the func.__code__.co_varnames property on the function func.

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 *