[issue38481] Class static property not static

2019-10-15 Thread Eric V. Smith
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

2019-10-15 Thread 楚艺
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() ---