Python introduces the new function syntax in Python3.8.2 Version, Where we can introduce the
/ forward slash to compare the positional only parameter which comes before the
/ slash and parameters that comes after
* is keyword only arguments. Rest of the arguments that are come between
* can be either positional or keyword type of argument.
That means we can combine positional arguments and regular arguments in such a way all the non-positional argument comes after
def function(a, b, /, c, d, *, e, f): # Function Body pass
Where a and b are positional argument, c and d can be either positional or keyword or e and f are strictly keyword type argument.
In the image given below, we can see that power function is a builtin function in Python’s math library and this function uses
/ slash to enable the positional only argument and now we can implement the same functionality with the help of this version.
Example #1 :
In this example we can see that by using positional only argument we can implement the function with the fixed position as we can say only in built-in functions before this python version. With the help of this, we are able to make our program more robust.
Example #2 :
- Python | Key-Value to URL Parameter Conversion
- Python | sep parameter in print()
- Python end parameter in print()
- Python | file parameter in print()
- Use of na_values parameter in read_csv() function of Pandas in Python
- Mahotas - Parameter-Free Threshold Adjacency Statistics
- Python | Split and Pass list as separate parameter
- Precedence and Associativity of Operators in Python
- How to Learn Python in 21 Days?
- Visualising ML DataSet Through Seaborn Plots and Matplotlib
- How to make a Google Translation API using Python?
- numpy.linalg.eig() Method in Python
- numpy.linalg.det() Method in Python
- numpy.einsum() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.