ich hab leider einen Knoten im Gehirn, kann mal jemand auf den Code schauen
in der Instance von PartAll wurden zwei Part objekte erzeugt,
nun soll ein nset in ein nsetAll gepackt werden und dieses zu part 1 hinzugefügt werden,
wie komme ich da hin?
Code: Alles auswählen
class Model:
def __init__(self):
self.partAll = PartAll()
class PartAll:
def __init__(self):
self.partDict = {}
def add_part_to_dict(self, part, part_id):
self.partDict[part_id] = part
def get_debug_output(self):
print self.partDict.keys()
class Part:
def __init__(self):
self.nsetAll = NsetAll()
class NsetAll:
def __init__(self): self.nsetDict = {}
def add_nset_to_nset_all(self, nset, id):
self.nsetDict[id] = nset
def get_debug_output(self):
print self.nsetDict
class Nset:
def __init__(self, value, id):
self.value = value
self.id = id
mod = Model()
part = Part()
mod.partAll.add_part_to_dict(part, 1)
mod.partAll.add_part_to_dict(part, 2)
mod.partAll.get_debug_output()
nset = Nset(1,1)
# add nset object to nset all and put nset all into part 1