Support unavailable
Please try again later

Magical attributes

Python lets you customize the behavior of your objects by defining special “double underscore” attributes on their classes. You can define the behavior of operators, the way the instances and classes are created, the way the attributes are accessed, the way inheritance is checked, etc. There is a lot of things you can do (and a lot of things you shouldn’t) with it.

In this talk we will look at the different “magic” attributes and see what they exactly do, and what they can be useful for and what kind of use should be avoided and why. We will look at common tricks employed by popular frameworks that turn Python into their own miniature domain-specific languages. We will also see how Python itself uses those mechanisms internally.

This talk is for people who are already familiar with the basics of Python, but would like to acquire some deeper understanding about it, and for advanced users who seek to organize their knowledge. At the end of the talk I want all of you to know what is the difference between init and new, how metaclass and subclasscheck work, and how slots uses the descriptor protocol.

in on Friday 5 July at 09:45 See schedule

Do you have some questions on this talk? Leave a comment to the speaker!

New comment

Download slide (ZIP Archive)
(Size: 176.0 KB)

Language
EN
Duration
45 minutes (inc Q&A)

Tagged as

best-practices hacking api design
Our Sponsors
Spotify
Python Experts
SSL Matrix
Wanna sponsor?