Here I have an attribute 'a', which is defined in first class method and should be changed in second. When calling them in order, this message appears:
AttributeError: 'Class' object has no attribute 'a'
The only way I've found - define 'a' again in second method, but in real code it has long inheritance and app will be messed. Why doesn't it work? Isn't self.a equal to Class.a?
class Class(object):
def method_1(self):
self.a = 1
def method_2(self):
self.a += 1
Class().method_1()
Class().method_2()