I am new to OOP with python. I have 3 classes with one being called from the other as a parameter instance:
class Characters:
def __init__(self, b="", c = ""):
self.b= b
self.c= c
class Words:
def __init__(self, charss=Characters()):
self.charss= charss
class Sentences:
def __init__(self, w=Words()):
self.w = w
I am then creating a new instance of class Words form another Class and filling it with data i have from a json file.
s = Sentences()
s.__dict__ = json.loads(output.content)
When debugging i can see that s is populated correctly. I am then trying to print out the values of s like this:
print(s.w[0].charss[0])
an error occurs:AttributeError: 'dict' object has no attribute 'charss'
is it because I am populating from the JSON as __dict__ where charss instantiated as list. If that is so what would be the best solution changing the __dict__ from json input or instantiating the object as __dict__?