filmov
tv
Python - How to Accept Only Keyword Arguments in a Function
Показать описание
#Python #Shorts
To make your code easier to read, especially for those not familiar with the codebase, for certain functions in Python you may want to only allow the keyword arguments. Which means that in order for you to use the function, you have to pass in each parameter value with the name of the argument. And it's easily done in Python. Just "skip" all positional arguments with an asterisk (*), and put your keyword arguments after it.
-------------------------------------------------------------------------------------
Links:
To make your code easier to read, especially for those not familiar with the codebase, for certain functions in Python you may want to only allow the keyword arguments. Which means that in order for you to use the function, you have to pass in each parameter value with the name of the argument. And it's easily done in Python. Just "skip" all positional arguments with an asterisk (*), and put your keyword arguments after it.
-------------------------------------------------------------------------------------
Links: