How can we pass optional or keyword parameters from one function to another in Python?



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

Post New Answer

More Python Interview Questions

What is __ init__ in python?

0 Answers  


Explain me five benefits of using python?

0 Answers  


Which is better perl or python?

0 Answers  


what is random module will do in python and what are the functions we can apply on random module

0 Answers  


Where is freeze for windows?

0 Answers  


What is __ new __ in python?

0 Answers  


What are the generators in python?

0 Answers  


What is lambda in Python?

0 Answers  


Write a code to display the current time.

0 Answers  


What is the directory in python?

0 Answers  


What is flask-wtf and what are their features?

0 Answers  


How does Python handle the memory management?

0 Answers  


Categories