I've read that there is no strict enforcement of Encapsulation in Python. slots is generally used for purposes of faster attribute access and memory savings as reflected in here. However can encapsulation be enforced strictly with the usage of slots and decorators as shown in the following code:
class GetSet(object):
__slots__ = ["attrval"]
def __init__(self,value):
self.attrval = value
@property
def var(self):
#print 'getting the "var" attribute'
return self.attrval
@var.setter
def var(self,value):
#print 'setting the "var" attribute'
self.attrval = value
@var.deleter
def var(self):
#print 'deleting the "var" attribute'
self.attrval = None
An instance of GetSet won't have dynamic variable setting(due to slots) and also the setter and getter methods would invoke the method definitions in the class. Isn't encapsulation invoked entirely?