Below is how I create and use a namedtuple object:
>>> from collections import namedtuple
>>> labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
>>> data = namedtuple('data', labels)
>>> my_data1 = data(a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=8, j=9)
>>> my_data1
data(a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=8, j=9)
Instead of having to manually type this multiple times:
my_data1 = data(a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=8, j=9)
How do I write a for-loop or use a comprehension approach to write this?
E.g. if values is a list object, e.g. list(range(10)) or a list of any values, how do I create a new instance of data
with a for-loop and different list of values?