fork download
  1. class test:
  2. num=64
  3. pow=None
  4.  
  5. def __init__(self):
  6. if test.pow==None:
  7. test.pow=[(test.num+a) for a in range(0,5)]
  8. print('- initialized')
  9.  
  10. def output(self):
  11. print('num',test.num)
  12. print('pow',test.pow)
  13.  
  14.  
  15. print('-- not init')
  16. print(test.pow)
  17.  
  18. print('-- new c1')
  19. c1=test()
  20. c1.output()
  21.  
  22. print('-- new c2')
  23. c2=test()
  24. c2.output()
  25.  
Success #stdin #stdout 0.03s 63656KB
stdin
Standard input is empty
stdout
-- not init
None
-- new c1
- initialized
('num', 64)
('pow', [64, 65, 66, 67, 68])
-- new c2
('num', 64)
('pow', [64, 65, 66, 67, 68])