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 |
How is unit test done in python?
How would you randomize the contents of a list in-place?
List out standard datatypes in python
What is format () in python?
Write a program to find the duplicates in a list?
How to make a chain of function decorators?
What is python namespace?
Is python better than matlab?
How do I convert a number to a string?
What is tuple in python?
What is class super?
What are cookies python?