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__.py used for?

0 Answers  


Explain about repr function?

0 Answers  


1) How to validate ip address using regex 2)program to increment ip address in python Please find answers to above questions thanks in advance.

0 Answers  


What packages in the standard library, useful for data science work, do you know?

0 Answers  


How do you add in python?

0 Answers  






Explain about dir() and help() function will do in python?

0 Answers  


What are the runtime errors?

0 Answers  


What does exit () do in python?

0 Answers  


Why does it say none in python?

0 Answers  


Which is better PHP or Python?

0 Answers  


What are the differences in the deep and shallow copy?

0 Answers  


Mention the floor division available in python

0 Answers  


Categories