I'm trying to figure out how to construct a class in python where I have nested variables.
In practice, we are measuring a thing called a "Device". Each "Device" has multiple physical measurement locations called "Wells". And each "Well" in measured at various time "Intervals".
I've been trying to create a class in Python to create an object called a "Device". Each device may have multiple "Intervals" which I've placed into a list. The part I'm having difficulty with is how I can associate the measurement data from a particular well with a specific interval.
My data looks something like this:
Device1 -> 0hr -> Well 1 -> Data
Device1 -> 0hr -> Well 2 -> Data
Device1 -> 1hr -> Well 1 -> Data
Device1 -> 1hr -> Well 2 -> Data
It's worth noting that the number of intervals and number of wells for each device is variable.
I know it's not much but here's what I have so far.
class device(object):
def __init__(self, name):
self.name = name
self.intervals = []
def add_interval(self, interval):
self.intervals.append(interval)
def main():
d1 = device('Control')
d1.add_interval(0)
d1.add_interval(24)
d1.add_interval(48)
print(d1.intervals)
Any suggestion would be greatly appreciated.