~/talk

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

Talkat PyCon US 2022 · 2022-04-27..05-03· [python]
slides:none on file

Explains exactly what the dot does and why attributes drive Python behavior with concrete examples: variables vs object attributes, a population counter moved from a broken global into a class attribute, class bodies executing at definition time (demo prints order a b d e c c), how __init__ actually adds attributes, and how inheritance requires calling super to run parent __init__. Dives into ICPO (instance class parent object) lookup, the descriptor __get__ protocol and how it produces bound methods via functools.partial, and recommends properties as simpler descriptors.

AI-written summary · about

  1. 0:00Intro
  2. 0:47I teach Python!
  3. 1:11Let's assign to a variable!
  4. 2:12Let's get fancier
  5. 2:57Variables vs. attributes
  6. 3:24Reading from attributes
  7. 4:29Setting attributes
  8. 5:40We set attributes all the time
  9. 7:28What's missing from this program?
  10. 8:11Idea: A global variable
  11. 10:28A better alternative
  12. 11:15This is pretty ugly
  13. 11:35What will this code print?
  14. 11:57The answer
  15. 14:08Methods are class attributes
  16. 14:37Classes are file-less modules
  17. 15:25Class attribute, nicer edition
  18. 15:57Static variables.!?
  19. 17:47Let's walk through this
  20. 18:48A new version of Person
  21. 19:36We need a new class
  22. 20:41Does it work?
  23. 21:14Try again, but with inheritance
  24. 21:58Let's use inheritance
  25. 22:09Better use of inheritance
  26. 23:48The problem?
  27. 24:33Solution: Explicitly call Person.init
  28. 24:46Better: Use super
  29. 25:27Printing our objects
  30. 26:23Operator overloading
  31. 26:41Something is still missing
  32. 28:44Example
  33. 29:41Use it in a class attribute
  34. 31:09Retrieve the value
  35. 31:54What are gets parameters?
  36. 33:25Methods are descriptors
  37. 35:37Where is our original function?
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.