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 is “self” explicitly defined in a method?
Why python language is called python?
Can you write an efficient code to count the number of capital letters in a file?
What is dict in python?
What is the use of sessions in Django?
What is an f string in python?
How install pip python ubuntu?
Are there arrays in python?
How to write a text from from another text file in python ?
What’s your preferred text editor?
Does anaconda automatically install python?
What does __ file __ mean?