Talks: Understanding attributes (Or: They're not nearly as boring as you think!)

Presented by:


Description

Attributes in Python, which we use dozens of times each day, seem boring, obvious, and not worthy of attention. But it turns out that they're key to the Python language: Every time you say a.b in Python, that little dot is hiding a lot of work, from searching across multiple objects to silently rewriting things. And it turns out that what happens with attributes, while not always obvious to developers, determines a great deal of behavior in the Python language.

In this talk, I'll discuss what attributes are (and aren't), what Python does when you use a dot (.) in your code, and how you can take advantage of it. We'll talk about attribute lookup, about inheritance, and about methods vs. functions. We'll also look into properties, and how they allow us to have attributes that look like data but behave like setters and getters. Finally, we'll look at the descriptor protocol, which makes so much of Python's functionality possible, including the automatic insertion of "self" as the first argument in method calls.