Use the *args
syntax to apply each item in t
as a separate argument:
RowSource(*t)
Alternatively, use the namedtuple._make()
class method:
RowSource._make(t)
The latter has a slightly more helpful TypeError
exception message:
>>> from collections import namedtuple
>>> SampleTuple = namedtuple('Sample', 'foo bar baz')
>>> SampleTuple(1, 2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __new__() takes exactly 4 arguments (3 given)
>>> SampleTuple._make((1, 2))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 17, in _make
TypeError: Expected 3 arguments, got 2
The __new__() takes exactly 4 arguments (3 given)
text while you clearly passed in only 2 throws some newer users of Python off, the namedtuple_make()
class method is slightly more informative here.