fork download
  1. class PrevCurr:
  2. def __init__(self, obj_initial):
  3. self.previous = obj_initial
  4. self.current = obj_initial
  5. def update(self, new):
  6. self.previous = self.current
  7. self.current = new
  8.  
  9. obj = [1]
  10. pc = PrevCurr(obj)
  11. obj.append(2)
  12. pc.update(obj)
  13.  
  14. print(pc.previous, pc.current)
Success #stdin #stdout 0.02s 9208KB
stdin
Standard input is empty
stdout
[1, 2] [1, 2]