fork download
  1. class myclass:
  2. def __init__(self):
  3. self.value = 0
  4.  
  5. def incr(self):
  6. self.value += 1
  7. return self.value
  8.  
  9. a = [5, 5]
  10. i = myclass()
  11.  
  12. print 'i:', i.value
  13.  
  14. a[i.value] = i.incr()
  15.  
  16. print a
Success #stdin #stdout 0.09s 10864KB
stdin
Standard input is empty
stdout
i: 0
[5, 1]