Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊSenior Deep-DivesModule 3 Β· Metaclasses + descriptors Β· Recapβ€ΊπŸŽ― Review: Senior Python module 3 recapscenario64 / 105
+80 XP
Task
Build a small plugin registry using the __init_subclass__ pattern (the lighter-than-metaclass way): 1. `PLUGINS` is a module-level dict mapping `name -> class`. 2. `Plugin` is a base class. `__init_subclass__` runs on any direct subclass and registers it under `cls.name`. 3. Re-registering the same name raises `ValueError("duplicate plugin: <name>")`. 4. `lookup(name)` returns the registered class or raises `KeyError(name)`.
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
πŸ“Š Result
Press Run to see result...

πŸ’¬ Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…