- JAVA can hide variables from outside using private variables
- like this, python can protect variables using property decorator
- When assigning value to property variable, it needs to go through setter class.
class C(object):
@property
def x(self):
"I am the 'x' property."
return self._x
@x.setter
def x(self, value):
"some expressions here"
self._x = value
@x.deleter
def x(self):
del self._x
# How to Use
myclass = C()
myclass.x = 3 # setter called
print x # property called