2👍
✅
The property approach is much simpler and causes less code to be written. I can’t super()-call a parent’s property function though.
You actually can access parent properties via super()
:
class A(object):
@property
def prop(self):
return 'A.prop'
class B(A):
@property
def prop(self):
return '%s - %s' % (super(B, self).prop, 'B.prop')
>>> b = B()
>>> b.prop
'A.prop - B.prop'
Source:stackexchange.com