How can we pass optional or keyword parameters from one function to another in Python?
Answer / chaitanya
Gather the arguments using the * and ** specifiers in the function's parameter list. This gives us positional arguments as a tuple and the keyword arguments as a dictionary. Then we can pass these arguments while calling another function by using * and **:
def fun1(a, *tup, **keywordArg):
...
keywordArg['width']='23.3c'
...
Fun2(a, *tup, **keywordArg)
| Is This Answer Correct ? | 0 Yes | 0 No |
What is the difference between a list and a tuple?
What good is recursion?
What is xrange in python?
is Python similar to ruby?
What is pip software in the python world?
How python supports encapsulation with respect to functions?
Which database is used in python?
Do you know what are the optional statements that can be used inside a <try-except> block in python?
How can you access a module written in python from c?
How can you access a session in flask?
How do you find missing values in python?
What does the map() function do?