Object Oriented Programming/Properties

From Wikibooks, open books for an open world
< Object Oriented Programming
Jump to navigation Jump to search

Properties in OOP are also able to be looked at as functions, a property houses a function that can have its procedures or variables altered without directly going to the code and editing it. A property can be changed or updated based on user input which allows for a lot of user-interactive programs and applications.

class Marker():

@property
def marker_color(self):
    return self._marker_color

@color.setter
def color(self, color):
    self._marker_color = Blue
    self._marker_color = Red


See Also[edit]

Wikipedia:Property(programming)

Python Programming/Classes