In Python 2.7, I'm trying to create classes within classes (and so on), like for example:
class Test(object):
def __init__(self, device_name):
self.device_name = device_name
class Profile(object):
def __init__(self, x1, x2):
self.x1 = x1
self.x2 = x2
class Measurement(object):
def __init__(self, x1, x2):
self.x1 = x1
self.x2 = x2
Using this layering to create objects, I need to be able to assign and access any variable in any layer, like for example:
test1 = Test("Device_1")
Test.Profile(test1, 10, 20)
Test.Measurement(test1, 5, 6)
print test1.Profile.x1
print test1.Measurement.x1
It should also be noted that I need to load the classes with data taken from a text file.
I thought that using classes would be the best way of achieving this but I'd be happy to hear any other ideas.