A untold story about “composition” and “multiple inheritance” in PYTHON

  1. Avoid multiple inheritance.
  2. Avoid super() keyword if possible (UNPREDICTABLE)
My reaction when everything made sense.
Multiple Inheritance on steroids
  1. Use multiple inheritance only when you absolutely understand how base classes during multiple inheritance are linearized using Class Resolution Algorithm.
  2. Understand the “method resolution order” and know how you can manipulate linearization during class resolution before abandoning “decorator” for composition.

--

--

--

https://github.com/RobusGauli

Love podcasts or audiobooks? Learn on the go with our new app.

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
Robus Gauli

Robus Gauli

https://github.com/RobusGauli

More from Medium

How to run PostgreSql using Docker and Python

Getting started with Python ASYNCIO [Part-1]

eventloop

mysqlclient with Python 3.10 / Docker

Setting up Django in Windows