Skip to main content
Loading page…
Python Mastery
Chapter 15
Lesson 3 of 3
Metaclasses
Contents
Notes
Tutor
Concept
What Is a Metaclass?
Loading activity…
Previous
1 / 10
Continue
Contents
Notes
Discussion
Tutor
30 min
10 activities
0 of 10 done
In this lesson
1
What Is a Metaclass?
2
Writing Your First Metaclass
3
Real-World Metaclass Patterns
4
A Singleton Metaclass
5
Metaclass Conflicts Are a Real Hazard
6
Build a Validation Metaclass
7
When Is a Metaclass the Right Tool?
8
Right Tool for the Job
9
The Metaclass Conflict Problem
10
Metaclass or Simpler Tool?
Objectives
Explain what a metaclass is and how type is the default metaclass
Write a metaclass with __new__ and __init__ to intercept class creation
Implement auto-registration, interface validation, and ORM-style patterns using metaclasses
Correctly judge when a metaclass is and is not warranted
Chapter 15 · Descriptors, Metaclasses & Class Internals
The Descriptor Protocol
How Classes Are Built
Metaclasses
Previous: How Classes Are Built
Next: Comprehensions