Overview
Syllabus
Intro
I teach Python!
Let's assign to a variable!
Let's get fancier
Variables vs. attributes
Reading from attributes
Setting attributes
We set attributes all the time
What's missing from this program?
Idea: A global variable
A better alternative
This is pretty ugly
What will this code print?
The answer
Methods are class attributes
Classes are file-less modules
Class attribute, nicer edition
Static variables.!?
Let's walk through this
A new version of Person
We need a new class
Does it work?
Try again, but with inheritance
Let's use inheritance
Better use of inheritance
The problem?
Solution: Explicitly call Person.init
Better: Use super
Printing our objects
Operator overloading
Something is still missing
Example
Use it in a class attribute
Retrieve the value
What are gets parameters?
Methods are descriptors
Where is our original function?
Taught by
PyCon US