I want to give a function values from a namedtuple which shares the same name as the function signature, and if the name doesn't exist in signature, skip it.
import collections
row = collections.namedtuple('row', ['b', 'a', 'c', 'd'])
row1 = row(1,2,3,4)
def assign_rows(a, b, c):
print(a, b, c)
assign_rows(*row1)
Returns error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-32-c5dc816f0d5d> in <module>
----> 1 assign_rows(*row1)
TypeError: assign_rows() takes 3 positional arguments but 4 were given
There are two problems, most obviously the error above, but also I want the argument to respect the name of the namedtuple, so a=row1.a, b=row1.b, c=row1.c. Is there a neat way to do this?