Главная
Study mode:
on
1
Intro
2
I teach Python!
3
Let's assign to a variable!
4
Let's get fancier
5
Variables vs. attributes
6
Reading from attributes
7
Setting attributes
8
We set attributes all the time
9
What's missing from this program?
10
Idea: A global variable
11
A better alternative
12
This is pretty ugly
13
What will this code print?
14
The answer
15
Methods are class attributes
16
Classes are file-less modules
17
Class attribute, nicer edition
18
Static variables.!?
19
Let's walk through this
20
A new version of Person
21
We need a new class
22
Does it work?
23
Try again, but with inheritance
24
Let's use inheritance
25
Better use of inheritance
26
The problem?
27
Solution: Explicitly call Person.init
28
Better: Use super
29
Printing our objects
30
Operator overloading
31
Something is still missing
32
Example
33
Use it in a class attribute
34
Retrieve the value
35
What are gets parameters?
36
Methods are descriptors
37
Where is our original function?
Description:
Explore the intricacies of Python attributes in this PyCon US talk by Reuven M. Lerner. Delve into the seemingly mundane yet crucial aspect of Python programming, uncovering the hidden complexities behind the simple dot notation. Learn about attribute lookup, inheritance, and the distinction between methods and functions. Discover the power of properties in creating attributes that behave like setters and getters. Examine the descriptor protocol and its role in enabling key Python functionalities, including the automatic insertion of "self" as the first argument in method calls. Through practical examples and clear explanations, gain a deeper understanding of how attributes shape Python's behavior and how to leverage them effectively in your code.

Understanding Attributes - They're Not Nearly as Boring as You Think

PyCon US
Add to list
0:00 / 0:00