How can we pass optional or keyword parameters from one function to another in Python?
Answer Posted / 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 View All Answers
Should I learn python or scala?
What is the difference between a tuple and a list?
Does the same python code work on multiple platforms without any changes?
What is a pep python?
What's the difference between python and anaconda programming?
What will be the output of data[-2] from the list data = [1,5,8,6,9,3,4]?
Give one example for multiple statements in single statement?
Is elif a keyword in python?
What is python’s standard way of identifying a block of code?
What is string replication operator in python?
which is the most commonly used package for data importing and manipulation?
What is an egg in python?
Explain me what is python and explain some of its benefits?
Is integer immutable in python?
What is the output of the following?