Learning by doing: Reading books and trying to understand the (code) examples
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
856 B

  1. #class Silly:
  2. #
  3. # def _get_silly(self):
  4. # print("You're getting silly")
  5. # return self._silly
  6. #
  7. # def _set_silly(self, value):
  8. # print("You're making silly {}".format(value))
  9. # self._silly = value
  10. #
  11. # def _del_silly(self):
  12. # print("Whoa, you're killing silly!")
  13. # del self._silly
  14. #
  15. # silly = property(_get_silly, _set_silly, _del_silly,
  16. # "This is a silly property")
  17. # same as before but with decorators:
  18. class Silly:
  19. @property
  20. def silly(self):
  21. "This is a silly property"
  22. print("You're getting silly")
  23. return self._silly
  24. @silly.setter
  25. def silly(self, value):
  26. print("You're making silly {}".format(value))
  27. self._silly = value
  28. @silly.deleter
  29. def silly(self):
  30. print("Whoa, you're killing silly!")
  31. del self._silly