The Wizardry of Metaprogramming
summary
Explains how Python’s type is the default metaclass so classes are constructed dynamically, shows that metaclasses can override __new__/__init__ (Django’s ModelBase sets field attributes via __new__), and demonstrates descriptors implementing __get__/__set__ descriptors to validate (SmallInt) or lazily load (deferred ORM fields) values. Uses Django and six as concrete examples, shows the mechanics work, and cautions that metaprogramming is powerful but rarely needed outside frameworks like ORMs.
AI-written summary · about
chapters (6)
related talks
01h 10mIt's Pythons All The Way Down: Python Types & Metaclasses Made Simple
33mMetaprogramming in Python
29mMetaprogramming with Decorators, Metaclasses, and Dynamic Code Generation
30mMetaclasses Demystified
25mThe Magic of Python
36mPractical Python Design Patterns
47mA Deep-Dive Into Python Classes
24mThe Ins and Outs of Model Inheritance
