BeginnerCoder

Lesson 22 — Metaclasses (expert)

Classes that build classes

A metaclass customizes how classes are created: its new receives the class namespace (ns, a dict of attributes) before the class exists, so you can add to it.

Why it matters: frameworks like Django use them to wire models automatically.

Want it another way?
Task

Make the metaclass add created = True to every class it builds, then print Model.created.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with Python Intermediate

Ready for more? Optional paid resources that pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.