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 |
How do you remove duplicates from a list in python whilst preserving order?
How to open a text file and display its contents?
Which of the languages does Python resemble in its class syntax?
What is final and super keyword difference between them?
Which database is best for python?
How do you execute a python script?
Explain about python’s parameter passing mechanism?
What is the length of your largest python code? Can you please describe the project?
Can you sort a string in python?
What is python slice()?
What is numpy array in python?
Is upper in python?