Advertisement
Guest User

BaseSetter

a guest
Sep 23rd, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. class P:
  2.   @property
  3.   def z(self): return 42
  4.   @z.setter
  5.   def z(self, value): print(value)
  6.  
  7. class PD(P): pass
  8.  
  9. p = PD()
  10. super(PD, p).z
  11. # prints 42
  12. super(PD, p).z = 21
  13. # Traceback (most recent call last):
  14. #  File "<stdin>", line 1, in <module>
  15. # AttributeError: 'super' object has no attribute 'z'
  16. super(PD, p).z(21)
  17. # Traceback (most recent call last):
  18. #  File "<stdin>", line 1, in <module>
  19. # TypeError: 'int' object is not callable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement