~/talk

The Magic of Python

Talkat PyOhio 2019 · 2019-07-27..07-28· [python]
links:none on file
slides:none on file

Introduces Python’s special (magic/dunder) methods and shows concrete examples for using them. Covers object initialization and representation (__init__, __repr__/__str__), numeric emulation (__add__ and similar), sequence emulation and iteration (__iter__, __getitem__), context managers (__enter__/__exit__), and using abc.AbstractBaseClass to gain functionality by implementing these methods.

AI-written summary · about

  1. 0:00Intro
  2. 1:09Agenda
  3. 1:30Magic Methods?
  4. 4:20Define Custom Behavior
  5. 7:25Enable Operator Overloading
  6. 12:16Emulate Container Types
  7. 14:56getitem__
  8. 16:53Use Case: Checking for interfaces
  9. 18:01Use Case: Offer Free Mixin Methods
  10. 19:53Context Managers
  11. 23:53@contextlib.contextmanager
  12. 24:42+ Python Data Model Documentation → Python collections module documentation → A guide to Python's Magic Methods
~/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.