Calling class variable with self
问题 How would you I came up with this interesting (at least to me) example. import numpy as np class Something(object): a = np.random.randint(low=0, high=10) def do(self): self.a += 1 print(self.a) if __name__ == '__main__': something = Something() print(something.__str__()) something.do() something2 = Something() print(something2.__str__()) something2.do() something3 = Something() print(something3.__str__()) something3.do() The above prints the following in the console: $ python test.py <__main_