Explaining Inheritance in Python Property Getters with the use of super()

The aim of this page📝 is to describe how python properties — getters — work with inheritance.

If interested, see also the previous installments on properties in Python in:

We are working with shipping containers and you want to retrieve their volume

We also have a special type of container — a refrigerated container — where its refrigerator takes 100 ft3 of extra space that has to be subtracted from the total

… override by duplication, however, is a bad practice … in other words, we should never define important rules more than once by the same code

The solution is to use super() to retrieve the base class property and modify by subtracting the damn refrigerator’s volume

--

--

Infrastructure Support Engineer/Technical Writer (snowplow.io) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pavol Kutaj

Infrastructure Support Engineer/Technical Writer (snowplow.io) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com