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 does means by split do in python?
How would you perform unit-testing on your python code?
Write a command to convert a string into an int in python.
What is the difference between .py and .pyc files?
What is abs in python?
Why is python faster than r?
How does xrange work in python?
Explain list, tuple, set, and dictionary and provide at least one instance where each of these collection types can be used.
How does ternary operator work in python?
Whenever you exit python, is all memory de-allocated?
What is the difference between Python and PHP?
What is the best python interpreter?
How to delete a file in python?
Are tuples hashable?
What does %d do in python?