Message354706
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):
D()
D num 1
D num 2
D num 3
D num 4
D num 5 |
|
Date |
User |
Action |
Args |
2019-10-15 07:47:21 | eric.smith | set | recipients:
+ eric.smith, paul.moore, tim.golden, zach.ware, steve.dower, chuyi |
2019-10-15 07:47:21 | eric.smith | set | messageid: <1571125641.33.0.645728489533.issue38481@roundup.psfhosted.org> |
2019-10-15 07:47:21 | eric.smith | link | issue38481 messages |
2019-10-15 07:47:21 | eric.smith | create | |
|