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 none mean in python?
how do I protect python code?
What is python's slice notation?
Is python easy to learn if you know c++?
Do you know what is the key difference between a list and the tuple?
Tell me is there a switch or case statement in python?
How many keywords are there in python? And why should we know them?
How are arguments passed by value or by reference?
does recursion cause any trouble?
Explain what is namespace in python?
How the memory is managed in python?
Can we use break in if statement in python?