Leonardo Giordani - Abstract Base Classes: a smart use of metaclasses

preview_player
Показать описание
"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.

Рекомендации по теме
Комментарии
Автор

Leonardo, your English is amazing. Very clear and insightful explanations. Great talk, too!

crogersdev
Автор

Apologies for the late replies (I didn't know this video was here :P). Thanks guys!

LeonardoGiordani
Автор

At first, I disliked the video, because it was hard for me to understand the pronunciation. But when I realized there’s almost no info in the internet, I came back and, you know, this video deserves a big like. Thank you for the explanation.

MrCyberthrone
Автор

Thanks! This is great. I feel like always when I hear meta and abstract in the same sentence it will be epic! :)

dj_e
Автор

Aaaah, this was a very nice presentation. I wasn't familiar with Virtual Class, but now it makes a lot of sense.

spinity
Автор

Ooo I was wondering if your t-shirt was the answer to Life, Universe and Everything : D, you do mention it, don't worry you have good sense of humor, English is fine too and of course thanks for the video its really helpful.

himanshikalra
Автор

What this talk was about? Some mix about this an that?

alexign
Автор

And what's the purpose of this talk? Why we use register and metaclass=SomeClass. This is SO empty talk!

arnoldwolfstein