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 does %s mean in python?
What is inside __ init __ py?
What does the function zip() do?
What is python shell scripting?
What is a flask?
What are local variables and global variables in python?
What is the difference between methods & constructors?
Explain important characteristics of python objects?
What are advantages and disadvantages of python?
How will you capitalize the first letter of a string?
Is python can be compatible with command prompt?
Can you use python to make apps?