I have a base class with a property which (the get method) I want to overwrite in the subclass. My first thought was something like:
class Foo(object):
d
Another way to do it, without having to create any additional classes. I've added a set method to show what you do if you only override one of the two:
class Foo(object):
def _get_age(self):
return 11
def _set_age(self, age):
self._age = age
age = property(_get_age, _set_age)
class Bar(Foo):
def _get_age(self):
return 44
age = property(_get_age, Foo._set_age)
This is a pretty contrived example, but you should get the idea.