How can we pass optional or keyword parameters from one function to another in Python?
Answer Posted / 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 |
Post New Answer View All Answers
What is the best tutorial for python?
Explain me what does the
What is the difference between ‘match’ and ‘search’ in python?
Is empty python dataframe?
Whats the difference between input() and raw_input()?
Is geany good for python?
How to convert a list into a tuple?
What is __ init__ in python?
What static means?
How do I use strftime in python?
What do you understand by python generator?
How to set the figure title and axes labels font size in matplotlib?
What is the language from which Python has got its features or derived its features?
How to find the index of an element in a list python?
What are static methods for?