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 |
Does python have multiple inheritance?
What are the different file-processing modes with python?
How do I start learning python?
How do you check if two objects are the same in python?
What is orm in python?
List down some of the pdb commands for debugging python programs?
What is lambda used for in python?
What does time time () do in python?
Convert a string representation of list to list.
What is the purpose of a // operator?
Can we overload constructor in python?
Why do we need to overload operators?