A namedtuple()
is nothing but a class generated with a factory function:
SomeRowResult = namedtuple('SomeRowResult', 'var1 var2 var3')
Here SomeRowResult
is a class object (a subclass of tuple
), and calling it will create instances of the class:
for result in results:
result = SomeRowResult(table1.col1, table2.col1, table3.col1)
If you wanted to have a list of these results, you need to explicitly build that list:
all_results = []
for result in results:
result = SomeRowResult(table1.col1, table2.col1, table3.col1)
all_results.append(result)