Leonardo Giordani - Abstract Base Classes: a smart use of metaclasses
Channel: EuroPython Conference
Date: 07/10/2017

"Abstract Base Classes: a smart use of metaclasses
[EuroPython 2017 - Talk - 2017-07-11 - PythonAnywhere Room]
[Rimini, Italy]

This talk shows what Python Abstract Base Classes (ABCs) are and how they can be used to categorise objects and implement a virtual inheritance tree. The goal of the talk is to introduce programmers to the concept of ABCs, and to show that metaclasses are not a terribly complex topic, but something that can be used by normal programmers. The talk is divided in three different “levels of difficulty”, each of one going deeper in the technical aspects of the subject.

Level 1: Polymorphism - Behaviours and delegation - Collections
The first level is meant to give a quick overview of the collections package and some useful code snippets. Even beginners can benefit of the information given here. To complete this level you only need to know what a try/except block is.

Level 2: Registering - Abstract Base Classes - Categories
The second level shows what real and virtual inheritance are, explains what is the meaning of registering and defines Abstract Base Classes. To complete this level you need to know what class inheritance is (i.e. what class MyList(list) means).

Level 3: Build your ABCs - Metaclasses - ABSs as interfaces
The third level shows how to create your own ABCs, why metaclasses are involved and why they are not a difficult concept. I will then quickly review a possible use of metaclasses as interfaces. To complete this level you need to know how to instantiate a class, and the difference between class and instance.

License: This video is licensed under the CC BY-NC-SA 3.0 license: https://creativecommons.org/licenses/by-nc-sa/3.0/
Please see our speaker release agreement for details: https://ep2017.europython.eu/en/speaker-release-agreement/