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 are the various types of operators in Python?
Why do we use __ init __ in python?
What is py4j?
How to convert a list into a set?
Explain garbage collection in python?
Explain pickling and unpickling in python?
Is python a pop or oop?
What happens if an error occurs that is not handled in the except block?
What is python inheritance?
Why c++ is faster than python?
How many variables are in python?
What sort does python use?