Python Passing Variables Between Classes 2
If you want to have more classes which is independent from others, you should use it like that. It is safer than other options I think because you pass the object file which includes all variables.
class C(): var1 = 7 var2 = “Moikka”
def __init__(self,num,text): self.var1 = num self.var2 = text
class D(): def __init__(self,otherClass): print (otherClass.var1) print (otherClass.var2)
object = C(5,”Hei”) object2 = D(object)
object3 = C(7,”Moi Moi”) object4 = D(object3)