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 instance of a class?

0 Answers  


is Python similar to ruby?

0 Answers  


Do you need python to run a python program?

0 Answers  


What happens when you execute python == python?

0 Answers  


What applications can you build with python?

0 Answers  






How do you write a function in python 3?

0 Answers  


What does len () mean in python?

0 Answers  


What is the sleeping time of python?

0 Answers  


What does .join mean in python?

0 Answers  


How can you share global variables across modules?

0 Answers  


What are special methods in python and how to implement?

0 Answers  


What are the disadvantages of Python Recursion?

0 Answers  


Categories