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 instance of a class?
is Python similar to ruby?
Do you need python to run a python program?
What happens when you execute python == python?
What applications can you build with python?
How do you write a function in python 3?
What does len () mean in python?
What is the sleeping time of python?
What does .join mean in python?
How can you share global variables across modules?
What are special methods in python and how to implement?
What are the disadvantages of Python Recursion?