How to call a property of the base class if this property is being overwritten in the derived class?

You might think you could call the base class function which is called by property:

class FooBar(Foo):

    @property
    def bar(self):
        # return the same value
        # as in the base class
        return Foo.bar(self)

Though this is the most obvious thing to try I think – it does not work because bar is a property, not a callable.

But a property is just an object, with a getter method to find the corresponding attribute:

class FooBar(Foo):

    @property
    def bar(self):
        # return the same value
        # as in the base class
        return Foo.bar.fget(self)

Leave a Comment