Ok I have two classes and one is dependent on the other. So I need to get a variable from the first class and use it in the second. But the second variable is constantly changing. Like this:
class class1 :
var1 = 0
def meth1 (self):
self.var1 += 1
class class2:
var2 = class1.var1
def see (self):
return self.var2
obj1 = class1()
obj2 = class2()
obj1.meth1()
obj2.see()
This would return 0 not 1. If I say print var1 in class one it prints that changed var. But when class2 gets it it is still 0... I guess it is still referring to the old var1. What am I doing wrong and what should I be doing?
Thanks
var1is not an instance variable. Why are you avoiding ordinary instance variables?