Life Under the A Guide to Python's Internal Conventions
summary
Demonstrates concrete behaviors: using single underscore as the REPL’s previous-result _, numeric separators for readable big integers, and underscore as a throwaway loop variable; overriding __add__ makes a numeric class concatenate strings instead of adding; double-underscore name mangling requires prepending the class name to access “private” attributes; __slots__ replaces per-instance __dict__ to reduce memory and speed attribute access but raises AttributeError when adding new attributes; implements __missing__ for safe dict-like lookup and contrasts data vs non-data descriptors where data descriptors force a getter/setter round trip.
AI-written summary · about
chapters (13)
- 0:00Python’s internal conventions
- 1:50Underscore in interactive shell
- 4:15Throwaway variables in data science
- 9:12Single and double underscore
- 13:09Dunder methods overview
- 15:40Dunder __name__ and __main__
- 17:49Common dunder methods
- 19:40Context managers
- 21:30__slots__ for performance
- 23:28Safe dictionary access
- 25:13Making classes callable
- 26:59Data vs non-data descriptors
- 30:15Summary and resources
related talks
30mUnder and Dunder - Python secret functions
16mUnder and Dunder - Python secret functions
32mEasier Classes: Python Classes Without All the Cruft
24mPython Peculiarities
01h 18mPython 103: Mmmm... Understanding Python's Memory Model, Mutability, and Methods
38mUnderstanding attributes (Or: They're not nearly as boring as you think!)
43mPython Improvements (or This Is Not Your Teacher's Python)
24m"A Confession of My Python Sins"
