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 length of your largest python code? Can you please describe the project?
Explain the Meaning of a single and double underscore before an object name?
How many variables are in python?
What is python keyword?
As python is more suitable for the server-side application, it is very important to have threading implemented in your server code. How can you achieve that in python?
What is Python Decorator?
What does the enum function in python do?
What applications use python?
Differentiate list and tuple with an example?
What is Dict and List comprehensions are?
What is type () in python?
Is python a good first language?
How to get the current time in python?
Tell me what are generators in python?
How do you create a list which is a reverse version on another list in python?