Understanding Attributes - They're Not Nearly as Boring as You Think
Offered By: PyCon US via YouTube
Course Description
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
Related Courses
Intro to Python for Brand New ProgrammersPyCon US via YouTube Comprehending Comprehensions
PyCon US via YouTube Data Analysis with SQLite and Python
PyCon US via YouTube Build a Production Ready GraphQL API Using Python
PyCon US via YouTube Web Development With A Python-backed Frontend - Featuring HTMX and Tailwind
PyCon US via YouTube