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 other way of checking truthiness?
how do I pass a variable by reference?
What is the difference between the shallow copy and deep copy in python?
Why do we say “a b c = 1000 2000 3000” is an invalid statement in python?
How many modes are there in python?
Explain me what are the principal differences between the lambda and def?
Should I learn c++ or python?
What is raw input function in python?
What is list comprehension? Give an example.
How to declare the variables function in python?
Is python shell scripting?
How do you avoid cyclic imports without resorting to imports in functions?