I need a construction like:
mainclass["identificator 1"].categories["identificator 2"].plots["another string"].x_values
I write this with many classes like:
class c_mainclass(object):
def __init__(self):
self.categories={}
self.categories["identificator 2"]=c_categories()
class c_categories(object):
def __init__(self):
self.plots={}
self.plots["another string"]=c_plots()
class c_plots(object):
def __init__(self):
self.x_values=[2,3,45,6]
self.y_values=[5,7,8,4]
mainclass={}
mainclass["identificator 1"]=c_mainclass()
#mainclass["identificator bla"]=c_mainclass(bla etc)
print(mainclass["identificator 1"].categories["identificator 2"].plots["another string"].x_values)
I'd like to define that all as "subattributes" within only one class like:
class c_mainclass={}:
setattr(mainclass["identificator 1"],"categories",{})
...etc.
What's the most practical way to do this?