Advertisement
andreymal

property test

Jan 5th, 2020
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. class Something:
  2.     @property
  3.     def radius(self):
  4.         return self.__radius
  5.  
  6.     @radius.setter
  7.     def radius2(self, radius):
  8.         self.__radius = radius
  9.  
  10.  
  11. s = Something()
  12. s.radius2 = 4
  13. print(s.radius2)  # 4
  14. print(s.radius)  # 4
  15. s.radius = 7  # AttributeError: can't set attribute
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement