~/talk

The Magic of Self How Python inserts self into methods

Talkat PyCon UK 2023 · on Sunday, 2023-09-24· at 12:30· Assembly Room· [python]
slides:none on file

Explains that the automatic first-argument insertion is not magic but the descriptor protocol, shows a hand‑written FavoriteDescriptor class implementing __get__ that returns True for a specific instance name, and demonstrates that normal functions are descriptors whose __get__ produces a bound method (a partial that prebinds the instance). Shows classmethod/staticmethod/property as wrapper descriptors, uses pseudo‑Python/C examples and a live instance/class demo proving the mechanism works.

AI-written summary · about

  1. 0:00Introduction
  2. 3:18Why do we have self
  3. 4:49About me
  4. 5:25Self in Python
  5. 10:31Object attributes
  6. 13:26Descriptor protocol
  7. 14:44Implement a simple descriptor
  8. 18:56Get method
  9. 21:02Other builtin descriptors
  10. 22:47Summary
  11. 23:39Recommendations
~/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.