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
.