[issue38481] Class static property not static
Eric V. Smith added the comment: When you assign to self.num, you're creating an instance variable which hides the class variable. Instead, assign directly to the class variable: class D: num = 0 def __init__(self): D.num += 1 print('D num', self.num) for i in range(5
[issue38481] Class static property not static
New submission from 楚艺 <1090217...@qq.com>: code: -- class D: num = 0 def __init__(self): self.num += 1 print('D num', self.num) for i in range(5): D() ---