fork download
  1. class Tmp:
  2. common_t = None # class variable
  3.  
  4. def __init__(self, t):
  5. self.t = t # instance variable
  6.  
  7.  
  8. Tmp.common_t = [1, 2]
  9. print(Tmp.common_t)
  10. t1 = Tmp([1, 2, 3])
  11. t2 = Tmp([4, 5, 6])
  12. t1 = t2
  13. t1.t[0] = 0
  14. t2.t[1] = 0
  15. print(t1.t)
  16. print(t2.t)
  17. print(Tmp.common_t)
  18. t1.__class__.common_t.append(3)
  19. print(Tmp.common_t)
Success #stdin #stdout 0.01s 9992KB
stdin
Standard input is empty
stdout
[1, 2]
[0, 0, 6]
[0, 0, 6]
[1, 2]
[1, 2, 3]