~/talk

The Magic of Self: How Python Inserts self Into Methods

Talkat XtremePython 2024 Online Conference · on Tuesday, 2024-11-19· [python]
slides:none on file

Shows working Python code that builds a Guitar class, a standalone play_note function and a custom Favorite descriptor that returns True for one instance and False for another, proving that functions are descriptors and Python’s function.__get__ creates a bound method. Explains the descriptor protocol’s three hooks (__get__, __set__, __delete__), contrasts property/classmethod/staticmethod behavior, and traces how CPython inserts the instance at attribute lookup time by combining function and instance into a callable.

AI-written summary · about

  1. 0:00Introduction to self
  2. 1:21The guitar class example
  3. 4:40Speaker introduction
  4. 4:54Debunking self misconceptions
  5. 9:30Classes and function objects
  6. 12:21Accessing class attributes
  7. 15:05The descriptor protocol
  8. 17:11Implementing a custom descriptor
  9. 21:34How functions use descriptors
  10. 23:10Built-in descriptors
  11. 23:58Summary and resources
  12. 24:54Epilogue and closing
~/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.