This is the website for an older EuroPython. Looking for the latest EuroPython? Click here!
Skip to main content

Subclassing, Composition, Python, and You

Level:
intermediate
Room:
pycharm (forum hall)
Start:
Duration:
45 minutes

Abstract

Ever seen a code base where understanding a simple method meant jumping through tangled class hierarchies? We all have! And while "Favor composition over inheritance!" is almost as old as object-oriented programming, strictly avoiding all types of subclassing leads to verbose, un-Pythonic code. So, what to do?

The discussion on composition vs. inheritance is so frustrating because far-reaching design decisions like this can only be made with the ecosystem in mind – and because there's more than one type of subclassing!

Let's take a dogma-free stroll through the types of subclassing through a Pythonic lens and untangle some patterns and trade-offs together. By the end, you'll be more confident in deciding when subclassing will make your code more Pythonic and when composition will improve its clarity.

TalkSoftware Engineering & Architecture

The speaker

Hynek Schlawack

Hynek Schlawack

Hynek Schlawack is a lead infrastructure and software engineer from Berlin / Germany, PSF fellow, maintainer of too many open-source projects, and contributor to even more.

His main areas of interest are networks, security, and robust software.


← Back to schedule