I've made a little progress on my understanding since submitting the poorly posed question below. I've gotten as far as this:
from collections import namedtuple
a = 3
Data = namedtuple('Data', 'b c')
d1 = Data(4,5)
d2 = Data(6,7)
data_list = (d1, d2)
def test1(a, *data) :
...
But *data is clearly not the correct syntax I seek for passing data_list. How do I structure this so the function knows that this is a namedtuple list, defined as Data.
In the function, I need to do something like: print 'A = ', a for each in data print 'BC = ', data.b + data.c
Original question below.
I'm an old hand at C, but new to Python, so my perspective is likely misaligned. I need to call a function with a couple of variables, and a list of a predefined set of values. I imagine something like this:
class TestData
def __init__(self, input, delay, result)
self.input = input
self.delay = delay
self.result = result
# (input, delay, result)
TestData list = [
(11, 250, 42)
(22, 500, 123)
(37, 100, 97)
]
RunTest(id, channel, list)
setup(id, channel)
for each in list
...
Can this work? Or am I headed in the wrong direction?
Please excuse me if I haven't entered the example code with the correct formatting.