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 use of map in python?
What is redis python?
Which compiler is best for python?
Explain the shortest way to open a text file and display its contents?
How would you randomize the contents of a list in-place?
What is instance method?
What are python scripts?
What is python used for at google?
What does slicing mean in python?
What is monkey patching?
How python does compile-time and run-time code checking?
What do you understand by python modules?