To override a setter in python 2 I did this:
class A(object):
def __init__(self):
self._attr = None
@property
def attr(self):
return self._attr
@attr.setter
def attr(self, value):
self._attr = value
class B(A):
@A.attr.setter
def attr(self, value):
# Do some crazy stuff with `value`
value = value[0:3]
A.attr.fset(self, value)
To understand where A.attr.fset came from see the documentation on the property class:
https://docs.python.org/2/library/functions.html#property