fork download
  1. def DefaultUpdate(self):
  2. self.x -= 1
  3.  
  4. def MyUpdate(self):
  5. self.x += 1
  6.  
  7. class A:
  8. def __init__(self, Update = DefaultUpdate):
  9. self.update = Update
  10. self.x = 0
  11.  
  12. a = A(lambda: MyUpdate(a))
  13. b = A()
  14.  
  15. a.update()
  16. b.update()
  17.  
  18. print(a.x)
  19. print(b.x)
Runtime error #stdin #stdout #stderr 0.04s 9248KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 16, in <module>
TypeError: DefaultUpdate() missing 1 required positional argument: 'self'