class_instance_override.py 169 B

12345678910
  1. # test that we can override a class method with an instance method
  2. class A:
  3. def foo(self):
  4. return 1
  5. a = A()
  6. print(a.foo())
  7. a.foo = lambda:2
  8. print(a.foo())