~/talk

The magic of "self": How Python inserts "self" into methods.

Talkat PyCon US 2021 · 2021-05-14..05-15· [python]
slides:none on file

Claim: Python inserts the instance by making plain functions into descriptors whose __get__ creates a bound method so the instance becomes the first arg. Tools shown: the descriptor protocol (implementing __get__), a handwritten FavoriteDescriptor that compares an instance.name to "warwick streamer", and demos of property, classmethod, staticmethod. The descriptor demo returns True/False as expected and the manual invocation of get(None) vs get(instance) reproduces the exact behavior that produces automatic self binding.

AI-written summary · about

  1. 0:00Introduction
  2. 1:50About me
  3. 3:17The basics
  4. 5:53Defining a class with methods
  5. 10:33What are descriptors
  6. 12:32Implementing a descriptor
  7. 18:18decorators
  8. 20:14Summary
  9. 22:14Conclusion
~/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.