1 min read
How can I pass optional or keyword parameters from one function to another?
Vishal Sharma Answered question June 29, 2019
1 min read
Collect the arguments using the * and ** specifiers in the functions parameter list; this gives you the positional arguments as a tuple and the keyword arguments as a dictionary. You can then pass these arguments when calling another function by using * and **:
def f(x, *args, **kwargs): kwargs['width'] = '14.3c' g(x, *args, **kwargs)
Vishal Sharma Edited answer September 4, 2020