class_getattr.py 462 B

12345678910111213141516
  1. # test that __getattr__, __getattrribute__ and instance members don't override builtins
  2. class C:
  3. def __init__(self):
  4. self.__add__ = lambda: print('member __add__')
  5. def __add__(self, x):
  6. print('__add__')
  7. def __getattr__(self, attr):
  8. print('__getattr__', attr)
  9. return None
  10. def __getattrribute__(self, attr):
  11. print('__getattrribute__', attr)
  12. return None
  13. c = C()
  14. c.__add__
  15. c + 1 # should call __add__