Making Multiple Inheritance not work in Python

Andy Fundinger

Abstract

This talk is a destructive examination of the workings of Python's inheritance model. We'll learn how it works by breaking it. After starting with a discussion of how we got to where we are, we'll then move on to the hooks that Python gives us to interact with it.

Description

This talk is a destructive examination of the workings of Python's inheritance model. We'll learn how it works by breaking it. After starting with a discussion of how we got to where we are, we'll then move on to the hooks that Python gives us to interact with it. These include using the metaclass to alter the class during construction, as well as using the __init_subclass__ and __subclasscheck__ hooks.

Particular examples will include:

  • Implementing interfaces in Python
  • Turning inheritance off in favor of explicit reuse
  • Simplifying classes by disabling a selection of features you don't wish to use

While none of these are meant to be particularly useful implementations, they make good use cases to show the machinery.

Bio

Andy Fundinger is a senior engineer at Bloomberg, where he develops Python applications in the Data License group and supports Python developers throughout the firm through the company's Python Guild. Andy has spoken several times at PyGotham, as well as other conferences such as QCon, PyCaribbean, and EuroPython.

In the past, Andy has worked on private equity and credit risk applications, web services, and virtual worlds. Andy holds a Masters of Engineering from Stevens Institute of Technology. In his spare time, Andy is a maker who works on Internet of Things (IoT) projects and teaches classes at MakerBar in Hoboken, NJ.