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 |
Why does it say none in python?
What objects are iterable in python?
How do you execute a python script?
What is an f string in python?
How do I run a subprocess with pipes connected to both input and output?
Write a command to convert a string into an int in python.
What is the difference between lists and tuples?
How do you disconnect from the database?
What is design pattern in python?
What are its benefits of flask?
How to count the number of instance?
What is threads life cycle?