User Tools

Site Tools


python:python_misc:properties_in_python_classes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
python:python_misc:properties_in_python_classes [2019/02/19 22:58] – created mithatpython:python_misc:properties_in_python_classes [2019/02/19 23:12] mithat
Line 1: Line 1:
 +Good writeups:
 +  * https://stackabuse.com/the-python-property-decorator/
 +  * https://www.programiz.com/python-programming/property
 +
 <code python> <code python>
 class ClickerCounter(): class ClickerCounter():
Line 7: Line 11:
     def click(self):     def click(self):
         """         """
-        Click the counter: advance the count by one and reset if +        Advance the count by one and reset if over the upper limit.
-        over the upper limit.+
         """         """
         self.count = self.count + 1         self.count = self.count + 1
Line 25: Line 28:
     @limit.setter     @limit.setter
     def limit(self, l):     def limit(self, l):
-        """Set a new count limit"""+        """Set a new count limit."""
         if l > 0:         if l > 0:
             self.__limit = l             self.__limit = l
python/python_misc/properties_in_python_classes.txt · Last modified: 2019/06/21 23:16 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki